hel.io
Explore posts from serversSolid.js event handler that depend on reactive value best practice (fix solid/reactivity lint rule)
Hi Josh,
Im quite new to SolidJS, been mostly working with react. In react, because of its nature, we try to avoid passing a callback to a component like this
<button onClick={() => props.onClick()}>My button</button>
, I try to always do <button onClick={props.onClick}>My button</button>
however, you are saying that, in SolidJS we should do as the first example? Is this because the nature of SolidJS where functions only run once?
From what I understood is that as long as you dont destructure your props, you don't lose reactivity. I'm trying to understand why passing props.onClick
would not be OK.
Thanks10 replies
Solid.js event handler that depend on reactive value best practice (fix solid/reactivity lint rule)
I've seen these too but I'm wondering if it's not an issue with eslint plugin solid. I don't see anything wrong to how you pass the onClick event handler to your component in your first button.
I'd love, however, know if it's really just an issue with the eslint plugin or if there's a better way to do this.
10 replies
How to extend native events
This would probably be a good place for a Proxy https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy.
I mean, not necessarily in the input itself but you could create a proxy for the currency and you can do whatever you need on
set()
and on get()
, which is where you could provide your masked
and unmasked
values2 replies