Skip to content

What are the benefits of passing a proxy using context? #788

Answered by dai-shi
leochiu-a asked this question in Q&A
Discussion options

You must be logged in to vote

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} />
    </>
  );
};

Replies: 1 comment

Comment options

You must be logged in to vote
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
Category
Q&A
Labels
None yet
2 participants