i want to use the data from redux store at my root level, for that purpose i created a seperate entry file main.js as mentioned in expo documentaion but now my app isnot running?
Pleas help me to fix this
i tried
my main.js file
import { registerRootComponent } from "expo";
import { Provider } from "react-redux";
import Index from "./app";
import { store } from "./store/store";
function Main() {
return (
<Provider store={store}>
<Index />
</Provider>
);
}
registerRootComponent(Main);
UPDATE NOV 7 2024
i found out that for every small change in my redux code the whole application reloads, so i need to get ridoff main.js file and change may root layout file as below
import { store } from "@src/store/store";
import { Provider } from "react-redux";
import MainLayout from "../components/MainLayout";
export default function RootLayout() {
return (
<Provider store={store}>
<MainLayout />
</Provider>
);
}
*I had to discard below one to stop whole app reloading when there is a change in redux code *
i was able to solve the problem, by changing my main.js as follows.
as mentioned here github issue
import { registerRootComponent } from "expo";
import { ExpoRoot } from "expo-router";
import { store } from "./store/store";
import { Provider } from "react-redux";
export function App() {
const ctx = require.context("./app");
return (
<Provider store={store}>
<ExpoRoot context={ctx} />
</Provider>
);
}
registerRootComponent(App);