Warning: React has detected a change in the order of Hooks called by

I have problem with Hooks order. What is funny, before I don’t have this problem. I was working on dark mode in my app and one time when I has reloaded my app console show me this problem. I didn’t touched this part of code where is this problem. Problem is in ‘loadEvents’ function:

export default function CalendarScreen() {

  const navigation = useNavigation();

  const [weeklyData, setWeeklyData] = useState([]);
  const [futureData, setFutureData] = useState([]);
  const [olderData, setOlderData] = useState([]);

  const todayDate = createDate()
  
  const { theme } = useDarkMode()
  const styles = createStyles(theme)

  const { language } = useLanguage();
  const getTranslatedText = (key) => {
    return appLanguage[language][key];
  }

  
  useEffect(() => {

    const loadData = navigation.addListener('focus', () => {
      loadEvents(setWeeklyData, setFutureData, setOlderData)
      console.log('loadEvents content in second file: ', loadEvents())
    });
    
    return loadData
  }, [navigation])

Here is the part of ‘loadEvents’ function in queries file:

export const loadEvents = (setWeeklyData, setFutureData, setOlderData) => {
    selectThisWeekEvents(setWeeklyData)
    selectNextWeekEvents(setFutureData)
    selectOlderEvents(setOlderData)
}

  
export const selectThisWeekEvents = (setWeeklyData) => {
  
    db.transaction(tx => 
        tx.executeSql(
            'SELECT '+ 
                'events.event_id,'+
                'events.title,'+
                'events.description,'+
                'events.subject_id,'+
                'events.class_id,'+
                'substr(events.deadline, 9, 2) || "." || substr(events.deadline, 6, 2) || "." || substr(events.deadline, 1, 4) AS deadlineDate,'+
                'substr(events.deadline, 12, 5) AS deadlineTime,'+
                'events.deadline,'+
                'subjects.subject_name, '+
                'classes.class_name '+
            'FROM events '+
            'RIGHT JOIN subjects ON events.subject_id = subjects.subject_id '+
            'RIGHT JOIN classes ON events.class_id = classes.class_id '+
            'WHERE events.title IS NOT NULL '+
            'AND events.deadline BETWEEN datetime('now') AND datetime('now', '+7 day') '+
            'ORDER BY events.deadline ',
            [],
            (_, {rows}) => {
                const data = rows._array;
                console.log('DATA -- This week events loaded: n', data);
                setWeeklyData(data)
            },
            (error) => console.log('ERROR -- Events loading failed' + error)
        )  
    )
}

In queries file, there is event data, but in second file there is undefined, console logs:

LOG  DATA -- This week events loaded:
 [{"class_id": 1, "class_name": "bbbb", "deadline": "2024-06-28T10:24:51.491Z", "deadlineDate": "28.06.2024", "deadlineTime": "10:24", "description": "asdasdsa", "event_id": 1, "subject_id": 1, "subject_name": "aaaa", "title": "proba 1"}]

 LOG  loadEvents content in second file:  undefined

Here is the error:

 ERROR  Warning: React has detected a change in the order of Hooks called by CalendarScreen. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks   

   Previous render            Next render
   ------------------------------------------------------
1. useContext                 useContext
2. useContext                 useContext
3. useState                   useState
4. useState                   useState
5. useState                   useState
6. useContext                 useContext
7. useContext                 useContext
8. useEffect                  useEffect
9. undefined                  useContext
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I have tried many options but anything works. Before i don’t have this problem and I didn’t modify this part of code.

When in app there is no events this error don’t show.

I tried to use callbacks.
I have read on stackoverflow other similar posts but they didn’t help me.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật