Getting context in click event (TanStack table + SolidUI)
So to get the x out of the way: I have a data table with a few thousand items, and I want to open a dialog (modal) when clicking on a row.
Instead of creating one SolidUI Dialog element (with all its content and trigger) per row, I wanted to create a single dialog at the root level and set its open state and content based on the row clicked.
So I made my context, wrapped my root in the provider (there's a bit of oddity here because SolidUI doesn't provide wrapping for the underlying kobalte context, but I'm fairly sure I did this correctly if not nicely), and then made an useContext wrapper. Now, if I use this wrapper in a component (Route.tsx line 36) it works fine, dialog pops up, content is in there. However, if I try to useContext in an onclick in a cell (line 25), useContext return null / the wrapper throws an error.
Is there something about how tanstack cells are rendered that would leave the context unavailable to it? Am I going about this the wrong way to begin with? I'm new to typescript and these sorts of frameworks so I may be overlooking something.
abbreviated code, hopefully it's enough to see what's going on, the rest of the code is still a huge mess.
https://gist.github.com/wizjany/390b2fd0a73b346a3a40b0c8128c000d
Instead of creating one SolidUI Dialog element (with all its content and trigger) per row, I wanted to create a single dialog at the root level and set its open state and content based on the row clicked.
So I made my context, wrapped my root in the provider (there's a bit of oddity here because SolidUI doesn't provide wrapping for the underlying kobalte context, but I'm fairly sure I did this correctly if not nicely), and then made an useContext wrapper. Now, if I use this wrapper in a component (Route.tsx line 36) it works fine, dialog pops up, content is in there. However, if I try to useContext in an onclick in a cell (line 25), useContext return null / the wrapper throws an error.
Is there something about how tanstack cells are rendered that would leave the context unavailable to it? Am I going about this the wrong way to begin with? I'm new to typescript and these sorts of frameworks so I may be overlooking something.
abbreviated code, hopefully it's enough to see what's going on, the rest of the code is still a huge mess.
https://gist.github.com/wizjany/390b2fd0a73b346a3a40b0c8128c000d
