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
nikivi
nikiviOP2y ago
I suspect its because const user = createUserState() like if I do this instead of const user = useUser() reactivity does not work or something
foolswisdom
foolswisdom2y ago
Because 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 do
nikivi
nikiviOP2y ago
so create new method
foolswisdom
foolswisdom2y ago
Is there a reason you don't want to?
nikivi
nikiviOP2y ago
like this?
foolswisdom
foolswisdom2y ago
I'm not sure what you mean?
nikivi
nikiviOP2y ago
or wait
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
you mean to do this i thought this wont work i have to create the store somehow this App is first component that loads
nikivi
nikiviOP2y ago
foolswisdom
foolswisdom2y ago
You already do. In the app
nikivi
nikiviOP2y ago
this is the provider
nikivi
nikiviOP2y ago
nikivi
nikiviOP2y ago
oh yes this is error i get if i do this
foolswisdom
foolswisdom2y ago
Right. But your sidebar is not accessing the store from the context, it's creating a new one
nikivi
nikiviOP2y ago
foolswisdom
foolswisdom2y ago
No
nikivi
nikiviOP2y ago
your sidebar is not accessing the store from the context, it's creating a new one
im confused
foolswisdom
foolswisdom2y ago
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
nikivi
nikiviOP2y ago
ohh ok
foolswisdom
foolswisdom2y ago
And the sidebar component is the component that sets showSettings
nikivi
nikiviOP2y ago
i see now thank you makes sense actually
foolswisdom
foolswisdom2y ago
👍 Just use useUser in the sidebar and everything should work

Did you find this page helpful?