Ghirigoro
Mapping props to attributes
A common pattern that comes up for me is creating components that expose the html attributes of their underlying element, while merging in their own values and defaults. For example something like this (this is not expected to work - just an example):
So my questions are:
1. Is this is a solved problem in Solid? I'm pretty new to the framework so I don't want to reinvent the wheel if there's an established idiom/library for this.
2. I'm not exactly clear on how the reactivity of props works. They don't seem to be a signal, so are they a store or do they have their own logic? When, where and how can they be modified? Should I wrap the guts of the component in a
createEffect
and expose the modified props through a signal?5 replies
Hydration Mismatch. Unable to find DOM nodes for hydration key
I'm trying to setup a SolidJS SSR project with Vite, Fastify, and the
@fastify/vite
plugin. I've finally got something rendering, but am getting this error:
The App
component this is happening in is as basic as you can get:
So basic in fact I'm not sure what there is to mismatch. I know it's not much info to go on but any leads on how to debug this would be appreciated.
P.S. - Even with the error the app renders properly on first render. Subsequent hot updates though are received by the browser but don't change what's rendered.6 replies
Create signal from store element
I have a component that takes signal as a prop:
Elsewhere I have a store that contains an array of numbers:
const [store, setStore] = createStore([1,2,3]);
My understanding is that SolidJS creates a signal for properties of stores. Is there a way to access that underlying signal so I can pass it to the input? I.e. <NumberInput value={store[0]/>
18 replies
How to react to length of store array?
I have a store representing an array:
Elsewhere I render a list based on that array:
pools.length
is always 0, even when I successfully add an element to the pool store. How do I get the value reactively?16 replies
Uninitialized signal in JSX but initialized in component
I have a component that is using an xstate machine to handle some state. At the top of the component I initialize the machine and set up a signal to handle the state, and then reference it in the JSX I return. The signal is initialized and works fine in the component body but is undefined in the JSX:
I'm new to Solid so I may be missing something about how components work, but the block at the top should execute before the return statement right? Is Solid doing some compiler magic that I'm not aware of? Dumb mistake elsewhere that I'm too undercaffeinated to see?
P.S. - This is being built with Vite and the Solid plugin.
P.P.S. - This seems to only happen with
Match
or Show
. If I use one of my own components I can access getState
just fine (e.g. <Heading>{getState().value}</Heading>
works fine)7 replies