-
I saw in the document that there are two ways to pass proxy-state, one is using modules and the other is using context. Using modules seems to be better for maintaining actions and states, so does passing proxy state using context have any clear advantages? |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Sep 9, 2023
Replies: 1 comment
-
You can reuse a component. Here's an example with props. (Context usage is basically the same.) const Component = ({ childState }) => {
const snap = useSnapshot(childState);
// ...
};
const Parent = () => {
return (
<>
<Component childState={state.foo} />
<Component childState={state.bar} />
</>
);
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
leochiu-a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can reuse a component. Here's an example with props. (Context usage is basically the same.)