Replies: 1 comment
-
You probably need "observer" somewhere. For more follow up questions please
follow the issue template instead, this is not enough info to provide
adequate help.
…On Tue, 14 Feb 2023, 23:22 Sebastian Bayerl, ***@***.***> wrote:
My application is using different tags where to render react components.
Is it possible to wrap a component with ChapterProvider
ìmport React from 'react';
import { useLocalStore } from 'mobx-react-lite';
import { chapterStore } from './ChapterStore';
export const storeContext = React.createContext<any>(null);
interface Props {
mainId: string;
}
export const ChapterProvider: React.FC<Props> = ({ children, mainId }) => {
const store = useLocalStore(chapterStore(mainId));
return <storeContext.Provider value={store}>{children}</storeContext.Provider>;
};
where chaptersSore is something like:
export const chapterStore = (mainId: string) => (): ChapterStoreIO => ({
updater: observable.box(0)
// ....
});
and when i call:
ReactDOM.render(<ChapterProvider mainId={ANY_MAIN_ID}>{ANY_COMPONENT_TO_RENDER}</ChapterProvider>, document.getElementById(tag));
for two different tags, then i wont get updates within the different
renders.
—
Reply to this email directly, view it on GitHub
<#3631>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN4NBDDWAAYUTH4HJU54TTWXQASLANCNFSM6AAAAAAU4DWKEM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My application is using different tags where to render react components.
Is it possible to wrap a component with
ChapterProvider
where chaptersSore is something like:
and when i call:
for two different tags, then i wont get updates within the different renders.
Beta Was this translation helpful? Give feedback.
All reactions