I am developing a React Native app using Expo SDK 50.0.11 and encountering a problem when trying to integrate Redux Toolkit and Firebase. Here are the issues and what I’ve tried so far:
Redux Toolkit Integration Issue:
When I add Redux Toolkit to my project, I receive the following error:
ERROR TypeError: 0, _toolkit.createSlice is not a function (it is undefined), js engine: hermes
ERROR Invariant Violation: “main” has not been registered. This can happen if:
This error disappears when I modify the metro.config.js as follows:
`const { getDefaultConfig } = require(‘@expo/metro-config’);
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.sourceExts.push(‘cjs’);
module.exports = defaultConfig;`
Firebase Integration Issue:
After the above fix, Firebase stops working. If I add the following line to the metro.config.js, Firebase starts working again, but Redux Toolkit then throws an error:
defaultConfig.resolver.assetExts.push('cjs');
How can I configure metro.config.js to work with both Redux Toolkit and Firebase without causing either to break?
Is there a specific order or method to load these extensions that could resolve the conflict?
I expected that modifying the metro.config.js to include both sourceExts and assetExts modifications would allow both Redux Toolkit and Firebase to function properly together without any conflicts.
ahmed rza is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.