Skip to content

Sharing state with library component #2044

Answered by cooltolia
cooltolia asked this question in General
Discussion options

You must be logged in to vote

Hello @dai-shi.
Just wanted to share the result of my research and say thanks for your help.
With your answers I started better understand the library plus it helped me with reading its source code.

As a result, the problem I shared is mostly related to the way how my projects are built.
Having two projects: core and feature package I ended up with loading two copies of jotai. Each used useAtom from its node_modules.
And with custom hook we actually set closure on usage of useAtom from one place.

Eventually it was easier simply set webpack alias for jotai to resolve it from direct node_modules and alway have only one source of library

Replies: 17 comments 41 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@dai-shi
Comment options

@cooltolia
Comment options

Comment options

You must be logged in to vote
4 replies
@dai-shi
Comment options

@cooltolia
Comment options

@cooltolia
Comment options

@dai-shi
Comment options

Comment options

You must be logged in to vote
6 replies
@cooltolia
Comment options

@dai-shi
Comment options

@cooltolia
Comment options

@dai-shi
Comment options

@cooltolia
Comment options

Answer selected by cooltolia
Comment options

You must be logged in to vote
4 replies
@dai-shi
Comment options

@itsjoeoui
Comment options

@dai-shi
Comment options

@dai-shi
Comment options

Comment options

You must be logged in to vote
7 replies
@dai-shi
Comment options

@shinchima
Comment options

@dai-shi
Comment options

@dai-shi
Comment options

@shinchima
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dai-shi
Comment options

Comment options

You must be logged in to vote
2 replies
@digoburigo
Comment options

@Nubebuster
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jelling
Comment options

@Orpheus29
Comment options

Comment options

You must be logged in to vote
3 replies
@Nubebuster
Comment options

@fjcalzado
Comment options

@dai-shi
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dai-shi
Comment options

Comment options

You must be logged in to vote
7 replies
@dai-shi
Comment options

@tval2
Comment options

@dai-shi
Comment options

@tval2
Comment options

@tval2
Comment options

Comment options

You must be logged in to vote
2 replies
@dai-shi
Comment options

@dbritto-dev
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment