S
SolidJS17mo ago
nikivi

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
nikiviOP17mo 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
foolswisdom17mo 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
nikiviOP17mo ago
so create new method
foolswisdom
foolswisdom17mo ago
Is there a reason you don't want to?
nikivi
nikiviOP17mo ago
like this?
foolswisdom
foolswisdom17mo ago
I'm not sure what you mean?
nikivi
nikiviOP17mo ago
or wait
nikivi
nikiviOP17mo ago
nikivi
nikiviOP17mo 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
nikiviOP17mo ago
foolswisdom
foolswisdom17mo ago
You already do. In the app
nikivi
nikiviOP17mo ago
this is the provider
nikivi
nikiviOP17mo ago
nikivi
nikiviOP17mo ago
oh yes this is error i get if i do this
foolswisdom
foolswisdom17mo ago
Right. But your sidebar is not accessing the store from the context, it's creating a new one
nikivi
nikiviOP17mo ago
foolswisdom
foolswisdom17mo ago
No
nikivi
nikiviOP17mo ago
your sidebar is not accessing the store from the context, it's creating a new one
im confused
foolswisdom
foolswisdom17mo 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
nikiviOP17mo ago
ohh ok
foolswisdom
foolswisdom17mo ago
And the sidebar component is the component that sets showSettings
nikivi
nikiviOP17mo ago
i see now thank you makes sense actually
foolswisdom
foolswisdom17mo ago
👍 Just use useUser in the sidebar and everything should work
Want results from more Discord servers?
Add your server