sibling function triggering
I've been beating my head against the wall and I'm looking for another suggestion.
In sidebar.jsx I have a list of names from a database. In a sibling comonent, main.jsx, I can rename that name in the database.
User clicks name in sidebar, it loads in main's form to rename and submit to database.
I can't seem to get the function that retrieves the list of names from the database to fire when the new name is submitted in main, and updates in the database.
I've tried using props from main to parent to sidebar.
I've tried using createRoot.
I've been putting the watcher in a createEffect in sidebar.
I just can't seem to get the function to re-fetch the database query and reload the list of names in sidebar.
Thoughts/Suggestions/Comments?
4 Replies
I can get values to change using those various methods, I just can't seem to fire a function on command (which I've been trying to use a stored value/signal). Maybe there's a better way?
I didn't want to go through all my code and refactor it to have all the logic in the parent and just pass down data to the children. I will if that's the way to do it.
Assuming you're using
createResource
, you would want to call the refetch
when the form is submitted. Depending on where the createResource
is used, it might be worth a slight refactor because you can't call the refetch
function from main if the resource is in the sidebar.Thanks. But I could call the refetch from the parent, and then just send an object down to the sidebar via a prop?
Yeah I suppose