Maciek50322
How to reduce undefined judgments
I mean in every context that executes after
onMount
(in which you set the engine
) you are guarenteed to have not null engine()
, so you can write engine()!.dispose()
Also if you don't like the !
you can do
19 replies
How to reduce undefined judgments
Well when you want to use the
engine
inside jsx, then Show
can do it the way I used it above.
Inside onMount
and createEffect
it's guaranteed that refs will not be nulls (if they are actually used / mounted).19 replies
How to reduce undefined judgments
You can do something like that with
<Show>
https://playground.solidjs.com/anonymous/759ff1d4-b587-4a1c-b14f-375556f39642
when you pass the function to <Show>
's children, you get the argument of accessor to truthy when
value19 replies
`createContext`, What's the point?
You can pass the component state to children, without knowing which ones will need / use this state, I used it like here:
Global state for this
DraggableNodesArea
doesn't really make sense here. I use the zoom to properly change nodes' x and y. If I were to retrieve the zoom
(which is controlled by DraggableNodesArea
) outside to App
just to pass them as props to DraggableNode
is just more mess, and the DraggableNodesArea
is reusable - you can have multiple "tree" states instead of one global5 replies
Proxy error
If you want to pass control to the function caller, you can do something like that:
I added
...configNextSetterArgs: any[]
,
(setState as any)
,
because typescript can't match the types for SetStoreFunction
, probably because it's quite complex5 replies
memo is rerun but any side effects subscribed are'nt reran
as suggested https://discord.com/channels/722131463138705510/958428791124951050/1269900932259381290 maybe these two sandboxes take different priorities in packages if duplication of dependencies is the case
61 replies
memo is rerun but any side effects subscribed are'nt reran
So
createWritableMemo
just doesn't work at all in playground
https://playground.solidjs.com/anonymous/ccb67468-0581-4d36-a7c9-0ee5cbac4e4a61 replies
memo is rerun but any side effects subscribed are'nt reran
There was an issue with
createWritableMemo
https://github.com/solidjs-community/solid-primitives/issues/633 but it's resolved, so maybe you don't have latest version?61 replies
Pass props from Component to props.children
If you only want to change class of the
Child
, which returns the html element, you can change it no problem with this:
https://docs.solidjs.com/reference/component-apis/children
like here
https://www.solidjs.com/tutorial/props_children
Also what's stopping you from doing:
10 replies
Question Relating to Arrays
Note that with
createMutable
lots of setting and getting signals is implicit, and you can create infinite loop with
Infinite loop happens, because array[0].x += 1;
is shorthand for array[0].x = array[0].x + 1;
and so on the left side we have implicit setter, and on right side we have implicit getter, that means the effect is subscribed to array[0].x
getter, but also it triggers change with setter array[0].x =
on the same entry, and because setter triggers getter, effect runs again after it sets new value22 replies
Question Relating to Arrays
Previously I created copies of array to let setters know that the value actually changed (because solid performs equality check on each set by default - this can be avoided with signal's options by doing)
With this
{ equals: false }
, everywhere value()
is used, it will be triggered on setValue
even if the previous value is the same22 replies