binajmen
Explore posts from serversis it ok to use `action()` to handle form submission in a SPA?
my idea is to handle form submission as follow:
but i'm wondering if there is a side effect i'm unaware of when in SPA mode 🤔
i believe actions were created for the SSR world, but perhaps i'm wrong and this usage is fine.
1 replies
How to set a new value in a store of `Record<string, __>`?
In the following example:
https://playground.solidjs.com/anonymous/07b233f7-59cb-4202-a3ca-595a497912f8
setValue("abc", 3)
on a blank object will trigger an error:
Probably because the internal of the Store's path syntax function is trying to access the data.
Am I suppose to use the Immer inspired produce
to add a new element to an object, or is there a syntax I don't know to use directly the setter from the store without using produce
?10 replies
Yet another reactivity problem :cry:
Hi,
This is a small reproduction of a problem I have with reactivity.
https://playground.solidjs.com/anonymous/ea30129e-e6d3-45aa-9345-192095a33f1b
My main question is why the DOM is not updated whereas I return from the context a getter function (that should trigger the reactivity, right?) while the data is correctly logged in the console
I based myself on this example:
https://github.com/solidjs/solid-realworld/blob/f6e77ecd652bf32f0dc9238f291313fd1af7e98b/src/store/index.js#L17-L31
12 replies
How do you delete an entry in an array when using `createStore`
In the following documentation, this case is not presented:
https://docs.solidjs.com/guides/complex-state-management
It could be trivial but I'm unsure of the right way for doing that 🙏
46 replies
Is this (completely 🫣) illegal in Solid world?
what is the best primitives/library to use when dealing with deep nested structure? the data I'm dealing with looks like a graph with nodes and leaves.
every nodes/leaves has a component that should update his data that should stay reactive.
pretty hard to explain the context 😅
I was thinking about using a createStore (globally or within a context)
23 replies
Is conditional rendering possible?
I have the following code:
getProgram
and postProgram
are wrappers around solid-query
.
When accessing the page with an id
in the query string (eg. ?id=123
) the first time, initialValues
equals to undefined
as the query is not yet finished and program.data
is undefined.
Then the query resolved and now program.data
is populated, but the form is already rendered so the form does not have any default values.
Hitting a second time the same page with the same id will lead to a populated form: the cache is already present so this time program.data
is defined.
Is it possiple to trigger a re-rendering à la React - (don't shoot me 🙈 ) - to rerun createForm with the actual data?
Or should I extract the createForm
+ <Form />
is a separate component and wrap it with a conditional <Show />
?22 replies
How do you keep reactivity?
I'm trying to organize my code but I lose the reactivity on the way...
When the
searchParams.id
value is set from undefined
to a correct string
value, I would expect the query to be executed and the effect to be triggered. It is not.
If I uncomment the createQuery
section instead of using getProgram
, it works.
11 replies
The props are reactive, right?
I've created a small wrapper around
solid-table
:
I use this component within a Suspense
. Therefore props.data is equal to []
, then populated with data. However, it doesn't seem to trigger an update. I tried to use a signal in the middle to make it reactive (see the comments) even if props.data
is already reactive. The effects are triggered and logging the data, but the table remains empty 🤔21 replies
Am I obliged to combine Suspense with Show?
I get the following error:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
I understand the cause, but I'm surprised. I was expecting that the Suspense
would delay the children until the data is available. Adding a Show
solves the issue, but I'm wondering if I can handle this differently.
22 replies
ReferenceError on something that should (and DO) exist
tl;dr: getting a reference error on an existing (declared and in scope) variable:
The best is to check this reproductible example:
https://stackblitz.com/github/binajmen/budget?file=src%2Fpages%2Fcategories.tsx
I'm pretty sure I'm doing something wrong, but I can't figure out what..
2 replies
How to choose between Store and Context?
I've gathered that a store can reside in its own file and be imported in multiple locations, acting as a shared state. Given this, why would I opt for a context when a store seems capable of handling the task?
Whether it's for theming or authentication status, a store seems apt. Is there an advantage to using a context, or some trade-offs or crucial factors I might be overlooking?
4 replies
How do you consume server actions response?
It might look as a silly question, but it is unclear for me how you must consume the response (either is it
result
or error
).
If the action failed (form validation, db error, etc.), I'd like to retrieve this info in the response. In the network tab, the result
as the type Response
(it makes sense). However, how am I suppose to consume the response and extract the JSON I'm sending from the action?4 replies
Thrown ServerError are not catched by ErrorBoundary
Am I the only one impacted by this?
https://github.com/solidjs/solid-start/issues/596
1 replies
Incoherent data with multiple createServerData$ in routeData
With the following route:
I'm expecting an array of different objects for the members and the invitations. But when consoling/using the two data sets,
invitations
has the same content than members
. If I change the declaration order in routeData
, then members
has the same content than invitations
.
Is this expected? Does that mean we can only have one createServerData$
in routeData
?2 replies
i18n solid primitive with SolidStart
I'm in a snake biting its own tail situation. Using @solid-primitives/i18n, I'd like to use the
/[lang]/...
param to indicate I18nProvider
which language to pick.
But I hit the error:
But useParams()
returns undefined. Most probably not working outside <Routes>
...14 replies