Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example request: Could you show an example of how to use this library with use-immer? #135

Closed
nratter opened this issue Jan 19, 2022 · 1 comment

Comments

@nratter
Copy link

nratter commented Jan 19, 2022

The immer team also makes a library called 'use-immer' to make it easier to use immer as a react hook. If this library would work well with react-tracked, could you provide an example of how to set up your store using this?

https://github.com/immerjs/use-immer

@dai-shi
Copy link
Owner

dai-shi commented Jan 19, 2022

It should work!

import { useImmer } from 'use-immer';
import { createContainer } from 'react-tracked';

const useValue = () => useImmer({
  first: 'react',
  last: 'hooks',
});

const {
  Provider,
  useTracked,
  // ...
} = createContainer(useValue);

See also our tutorial with bare immer: https://react-tracked.js.org/docs/tutorial-03/

@nratter nratter closed this as completed Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants