react-tracked causing error in react-native 0.72.7
tunghs217 opened this issue · comments
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
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
}
Is it the same as #193 and dai-shi/use-context-selector#110 ?
yes look like it a same error as #193 i still don't know why and what causing the error
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.
Can you investigate which version exactly causes the error?
https://github.com/facebook/react-native/releases
Thought unstable_batchedUpdates
is not implemented, but it's there:
https://unpkg.com/browse/react-native@0.72.7/index.js
Can you check this please?
dai-shi/use-context-selector#112 (comment)