Replies: 2 comments 2 replies
-
You can just use |
Beta Was this translation helpful? Give feedback.
1 reply
-
The consistent API with Solid is not passing signals. Basically never author components that expect Signals as a prop. We will wrap reactive expressions automatically. Read: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I started using
createStore
to manage my nested state object, and noticed a glaring inconsistency that should be fixed.If you build a custom component that expects a signal as a prop, passing a store value crashes the child component unless you create a memo, or pass it as an inline function. For example:
const MyComp = props => <div>{props.value()}</div>
With signals:
With store
The above crashes unless you do
<MyComp value={() => store.say}/>
There is literally never a situation where you would want to pass in a store value directly to a custom component. To a primitive component, it makes sense, but never to a custom component.
My idea is that solid should be changed to convert all store values passed in as props to functions (to maintain signal passing consistency), so that custom components expecting signals never get tripped up by passing in store values. This would remove the need to always wrap store values in functions when passing them into props (after realising the mistake was made). The result would allow:
MyComp would then not break as calling
props.value()
would work as expected. To summarise, this would break the inconsistent API surrounding store signals and regular signals.store.say
is already reactive so it shouldnt be adding overhead.Beta Was this translation helpful? Give feedback.
All reactions