store values do not update
have this store: https://github.com/learn-anything/learn-anything/blob/main/app/packages/electron-web/src/GlobalContext/user.ts
and this main component that first loads
https://github.com/learn-anything/learn-anything/blob/main/app/packages/electron-web/src/App.tsx
for some reason when I set the value of showSettings, the solid code does not rerun 🤔
specifically
<Show when={!user.user.wikiFolderPath || user.user.showSettings}>
this condition does not retrigger
I change the value of showSettings
100%GitHub
learn-anything/app/packages/electron-web/src/GlobalContext/user.ts ...
Organize world's knowledge, explore connections and curate learning paths - learn-anything/learn-anything
GitHub
learn-anything/app/packages/electron-web/src/App.tsx at main · lear...
Organize world's knowledge, explore connections and curate learning paths - learn-anything/learn-anything
23 Replies
I suspect its because
const user = createUserState()
like if I do this instead of const user = useUser()
reactivity does not work or somethingBecause every time you call createUserState, you are creating a new store, independent of the other ones
And you are calling setShowSettings on the instance created in the sidebar, rather than the instance created in the app component (which is also the instance passed to the UserContext)
In other words,
useUser()
is the right thing to doso create new method
Is there a reason you don't want to?
like this?
I'm not sure what you mean?
or wait
you mean to do this
i thought this wont work
i have to create the store somehow
this App
is first component that loads
You already do. In the app
this is the provider
oh yes
this is error i get if i do this
Right. But your sidebar is not accessing the store from the context, it's creating a new one
No
your sidebar is not accessing the store from the context, it's creating a new oneim confused
Your app component was fine as it was
Your context file was fine as it was
The problem is that you are creating a new state instance in the sidebar component
ohh
ok
And the sidebar component is the component that sets showSettings
i see now
thank you
makes sense actually
👍
Just use useUser in the sidebar and everything should work