Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-tracked causing error in react-native 0.72.7 #198

Closed
tunghs217 opened this issue Nov 30, 2023 · 8 comments · Fixed by #200
Closed

react-tracked causing error in react-native 0.72.7 #198

tunghs217 opened this issue Nov 30, 2023 · 8 comments · Fixed by #200

Comments

@tunghs217
Copy link

i create a new app and reimplement all the provider code like my old app that run in 0.72.3 but it throwing this error
simulator_screenshot_E2DAAE0E-41FF-49F3-AC1B-231FA518E169
here is my code
create container

const globalState = () => useState<GlobalState>({  })

export const { Provider, useTrackedState, useUpdate: useSetState } = createContainer(globalState)

using provider

const RootStack = createStackNavigator<RootParamList>();

export const PerferencesContext = React.createContext({
    changeSetting: (setting: iSettings) => { },
    localSettings: new Settings()
})

export default function Router() {
    const [localSettings, setLocalSettings] = useState<iSettings>(new Settings());

    //#region Load data in loading screen
    useEffect(() => {
        const init = async () => {
            AsyncStorage.getItem(CONSTANTS.LOCAL_SETTING_KEY, (err, result) => {
                if (err || !result) {
                    var settingnew = new Settings();
                    AsyncStorage.setItem(CONSTANTS.LOCAL_SETTING_KEY, JSON.stringify(settingnew));
                    return;
                }
                let settingConvert: iSettings = JSON.parse(result);
                setLocalSettings(settingConvert);
            })
        }
        init().finally(async () => {
            await BootSplash.hide({ fade: true });
        })
    }, [])
    //#endregion

    //#region LocalSetting create and listen
    const changeSetting = useCallback((setting: iSettings) => {
        AsyncStorage.setItem(CONSTANTS.LOCAL_SETTING_KEY, JSON.stringify(setting));
        return setLocalSettings({ ...setting });
    }, [localSettings]);

    const preferences = useMemo(() => ({
        changeSetting,
        localSettings
    }), [changeSetting, localSettings]);
    //#endregion

    //#region UI
    return (
        <Provider>
            <SafeAreaProvider>
                <PerferencesContext.Provider value={preferences}>
                    <PaperProvider>
                        <NavigationContainer>
                            <RootStack.Navigator screenOptions={{ headerShown: false }}>
                                <RootStack.Screen name='Login' component={LoginScreen} />
                            </RootStack.Navigator>
                        </NavigationContainer>
                    </PaperProvider>
                </PerferencesContext.Provider>
            </SafeAreaProvider>
        </Provider>
    )
    //#endregion
}
@dai-shi
Copy link
Owner

dai-shi commented Nov 30, 2023

Is it the same as #193 and dai-shi/use-context-selector#110 ?

@tunghs217
Copy link
Author

yes look like it a same error as #193 i still don't know why and what causing the error

@dai-shi
Copy link
Owner

dai-shi commented Dec 1, 2023

As I wrote somewhere, I don't know why either. It's a bundling issue, so once we know how it's causing the error, the fix might be trivial. Pretty sure that new metro bundler behaves something differently from the previous version.

@dai-shi
Copy link
Owner

dai-shi commented Dec 1, 2023

Can you investigate which version exactly causes the error?
https://github.com/facebook/react-native/releases

@dai-shi
Copy link
Owner

dai-shi commented Dec 1, 2023

Thought unstable_batchedUpdates is not implemented, but it's there:
https://unpkg.com/browse/react-native@0.72.7/index.js
image

@dai-shi
Copy link
Owner

dai-shi commented Dec 4, 2023

Can you check this please?
dai-shi/use-context-selector#112 (comment)

@tunghs217
Copy link
Author

tunghs217 commented Dec 5, 2023 via email

@dai-shi
Copy link
Owner

dai-shi commented Mar 2, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants