bigmistqke
hmr issues
Does anyone else have issues with solid's hmr recently? It happens to me quite often that hmr gets in a sort of loop where it keeps on building the same over and over. I can't kill the process, but have to terminate the terminal window when this happens.
1 replies
createMemo with `{equals: false}` not reactive
I am wondering if this is a bug or not:
The effect nor the jsx gets updated. Is this expected behavior?
playground
2 replies
setting signal inside createRenderEffect
say I have the following code
I assumed in the above example, first all the effects dependent of
other
would be run, so it would log after clicking 2 times
but instead we get
initially it is executed directly as it is declared, as expected, but then afterwards the effects will only run after the current effect is completed.
I understand it's not ideal to set signals during effects, probably for these sort of things, but I wonder if there is an escape hatch.
playground: https://playground.solidjs.com/anonymous/d4a6e547-9bd0-4b63-9e72-f47b25a16b015 replies
why is it possible to use singletons in astro but not solid-start?
when ssr'ing solid with solid-start it's advised not to simply import and export signals/stores, aka singletons, since this could create shared state on the server.
With astro on the other hand, this is a pattern that's being used with p.ex nanostores and the like. Is this potential bug of shared server state simply not possible in astro? Will we be able to share global state with singletons once solid-astro makes the move to astro?
6 replies
`Suspense` deep dive 🐬
I am dealing with some inconsistencies in how Suspense works between react vs solid while working on #solid-three. I wanna check up if my understanding of their mechanics is correct:
react
- In react, a
Suspense
is triggered by throwing a promise. This needs to be done in either the component-body or the jsx, no effects/memos. All code will run until that point. The code throws before anything can mount, nothing runs after the throw: no useEffect
and useLayoutEffect
, child-components do not run. The suspense-boundary catches the promise and re-renders its children once the promise is resolved.
- ✔️ <Suspense><div>{resource()}</div></Suspense>
- ✔️ <Suspense>{() => { resource(); return <></> }</Suspense>
- ✔️ <Suspense><Component prop={resource()}></Suspense>
- ❌ <Suspense>{() => { useLayoutEffect(() => resource()); return <></> }</Suspense>
will throw instead
solid
- In solid, a Suspense
is a 'special' signal. To trigger a Suspense
boundary, the signal needs to be added directly in the jsx-tree or used inside a createRenderEffect
or a createMemo
. Unlike react, using it directly inside the component body will not trigger Suspense
. Nothing throws, so code below the resource will still run. All siblings of the suspense will do their initial run. createEffect
and onMount
will only run once the resource is resolved, createRenderEffect
and createMemo
do run during initial run.
- ✔️ <Suspense><div>{resource() || resource}</div></Suspense>
- ❌ <Suspense>{() => { resource(); return <></> }</Suspense>
- ❌ <Suspense><Component prop={resource() || resource}></Suspense>
:(unless Component adds it to the jsx-tree or uses it inside createRenderEffect
/ createMemo
)
- ✔️ <Suspense>{() => { createRenderEffect(() => resource()); return <></> }</Suspense>
4 replies
1 property in `createMutable` with only 1 signal
I have a
createMutable
. Most of the properties in this object I want to be behaving like a regular createMutable
: all the properties are being represented by individual signals.
1 property on the other hand changes fast and will always be set as a whole, so as a performance optimization I would want this object to only occupy 1 signal, since this object can become rather large.
Is there a utility that can help with accomplishing this?6 replies
how to throttle effects
Is there a way to throttle effects?
Naive approaches, like slapping the callback of a createEffect in a throttle-function, don't seem to work (I assume it has something to do with the fact that it's sort of async-y)?
4 replies
createMemo with `equals: false` not reactive when mutating reference
I am trying to prevent to create
DOMMatrix
with each calculation, so I thought to mutate 1 with createMemo(() => ..., {equals: false})
, assuming it would trigger all subscriptions even when returning the same value (in this case the mutated DOMMatrix), but it doesn't as you can see: https://playground.solidjs.com/anonymous/1a137694-7267-439b-a7d3-8164a541e800
Anybody an idea how to approach this?7 replies
granularly derived store
My use-case:
I have an array of coordinates as input. For each coordinate I want to keep a set of offsets. The input can change, coordinates can get removed or added to the array.
I contorted something together with mapArray https://playground.solidjs.com/anonymous/981e35fd-a794-479e-a8dd-777306b24a87 but I wonder if there isn't something a bit more elegant/primitive-y to do the same.
4 replies
window.getComputedStyle returns react-style CSSStyleDeclaration?
if i
const style = window.getComputedStyle(node)
style has type CSSStyleDeclaration
which follows react's camelCase
formatting. I could cast it to JSX.CSSProperties
but JSX.CSSProperties
allow for numbers | string
while window.getComputedStyle
only returns string
.
what would be the solid way to type this?13 replies
minimal ssr|ssg-setup, general pointers for solid on the server
I am hacking around with having a solid jsx-template generate a typescript-file describing the schema (https://codesandbox.io/p/github/bigmistqke/solid-three-parser/master?file=%2Fsrc%2FCMSApp.tsx be aware it's a bit unconventional).
I have the typing sorted, but I need to open the browser to generate them. Ideally it would generate those types and save them in a file everytime I change them (inspired by payloadcms), without having to open the browser, but I am a bit puzzled with what would be the best way to approach that. It does not need reactivity, so I believe it could be done in node and ssr-mode, but am a complete noob regarding solid on the server so could really use some points.
I thought a more minimal set-up, compared to solidstart, could help for me to play around with this, but can not immediately find anything when googling. if something like this would be possible in solidstart i would also be interested in these suggestions!
6 replies
Keep 'DEV' in production-mode
I would like to make use of the $NAME-symbol from
solid-js/store
(for my experimentations at https://github.com/bigmistqke/solid-yjs-store, so i can allow multiple store-paths leading to the same reactive value). this is currently only exported as part of DEV afaik. Is there a way how to keep DEV available when doing a production-build?19 replies
setting getter in store on already defined key loses reactivity
in the above example store.alreadyDefinedKey.get will not update its value when store.value gets updated. is this expected behavior? can we only set getters when initializing its parent?
https://playground.solidjs.com/anonymous/972b3aec-d7df-4ec0-9a68-c8b8b60785e3
4 replies
client-side rendered solid-start, router and vercel
I am trying to deploy a CSR solid-start project to vercel.
When I enter the route from the root and then navigate to a sub-route, I get properly routed, but if i directly go to a route I get a 404. Locally it works as expected.
Is there something I need to add to my config for this to work?
2 replies
losing reactivity in For component
example repo: https://playground.solidjs.com/anonymous/b106963a-0ea6-4da2-a066-8bbf42bfc1f0
why is
todo.nested.data
not updated when i set the store?35 replies