Use Common Store in js file and edit it using file 1 then use it in file 2.
I have context.js file and it have following code.
I have file1.jsx file and it use to edit it.
How can I access store in context.js file from file 2.jsx? I need useeffect to run function when change store in context.jsx.
export function createI18n(i18n) {
const [store, setStore] = createStore({
...i18n,
t: i18n.t.bind({}),
});
const updateStore = (i18n) => {
setStore({
...i18n,
t: i18n.t.bind({}),
});
};
return [store, updateStore];
}I have file1.jsx file and it use to edit it.
const [i18nStore, updateStore] = createI18n(i18next);
const handleOnChange = (lang) => {
i18next.changeLanguage(lang).then(() => {
updateStore(i18next);
setTimeout(null, 10);
});
};How can I access store in context.js file from file 2.jsx? I need useeffect to run function when change store in context.jsx.
createEffect(() => {
console.log("Changed:", i18nStore.language);
});