Closed prakhargupta1 closed 1 year ago
As I was looking into this with Prakhar I think what's currently missing is ability to control state that could then be used by other components. I.e. if we used onClick
maybe we could have some global state setter where we can call setState(name: string, value: any) => void
and getState(name: string) => value: any
🤔
setState
can be done, getState
won't be necessary as all state is already available
setState
can be done,getState
won't be necessary as all state is already available
I also quickly tried doing globalThis.value = 3
but it seemed not to work, wondering maybe it would be even easier if we would allow "writing" directly to global state? 🤔
For that to work we'd need to detect when the user mutates global scope so that we can update the react state using setControlledBinding
accordingly in the runtime. The only way I can think of that working is by wrapping the global scope that we supply to these expressions with a Proxy
and detect when one of the nested properties has been assigned to. We'll also need to detect other things that can mutate, e.g. Array.push
.
Maybe that could be like a future goal and in the mean time having a setter sounds much more straightforward 🤔
Duplicates
Latest version
Summary 💡
On a click of a button, I wanted to choose a different query for a table. Basically, from a showing a specific id to showing all ids. Currently, this doesn't seem to be supported in Toolpad.
Examples 🌈
How it looks in retool: https://user-images.githubusercontent.com/92228082/212884443-13aa0484-935f-493c-a125-dc0c8270ec5a.mov
Configuration:
Motivation 🔦
No response