S
SolidJSĐăng Tú

`createEffect` doesn't working in `input.addEventListener('change')`

Here is source link: https://gitlab.com/ndt-challenge/dev.to/1st/-/blob/main/Glam%20Up%20My%20Markup/form.js?ref_type=heads Here is demo link: https://ndt-challenge.gitlab.io/dev.to/1st/glam-up-my-markup/ The createEffect seems to work fine expect when I try to set signal inside the input change event. What should I do to debug this case? Update to add more info: In the demo link, you will see the bug very clear when you try to update the select input. The expect way is the reset button should be change from disabled to not disabled.
GitLab
Glam Up My Markup/form.js · main · Challenges Accepted / DEV.to / 1...
on2024(20 Mar, 31 Mar) | demo: Glam-up My Markup
R
REEEEE16d ago
The object doesn't change You have the following options for solutions. You can use any of them: 1. setRecord({...rec}) 2. Use a store 3. Add {equals: false} to signal options which is the second parameter of createSignal Also, createEffect doesn't have a dependecy array like React so no need for the [nav(), record()] createEffect will track any signal read inside of it automatically
NT
Đăng Tú16d ago
But I still need it to compare to the old value, or did I do it wrong way?
R
REEEEE16d ago
you're return is fine, you don't need the second parameter for createEffect oh sorry No that's fine, I misread the code I thought you were trying to define a dependency array not set the initial value
NT
Đăng Tú16d ago
Thanks, so the signal actually use Object.is() (the one that compare by pointer) under the hook rgiht? (please correct me if I'm wrong)
R
REEEEE16d ago
I think the default is just === check
NT
Đăng Tú16d ago
Thanks for the options, I wonder what different between store and signal? Is store like an extenstion of signal or like redux store of reactjs?
R
REEEEE16d ago
Store basically will make every property of the object a signal once it's read so you can change only a certain property of the object and react to changes only to that property. With a signal, you have to replace the whole object and anything that's listening to the signal will react to the change even if you just changed one property In your example, you could only change rec.table and anything that's listening to that property will be notified but not anything that is listening to rec.length for example.
Want results from more Discord servers?
Add your server
More Posts
Typescript auto completion is broken in a monorepoHi, i've setup solidjs inside a mono-repo which has a react app as well. it seems my auto completioTernary and Show have unequal outputIn a basic Vite and Solid app, I have ```js const [page, setPage] = createSignal({ image: null, websocket get peers on the servercan you show an example of how to get websocket peers on the server solistartRouter isn't working.Why routing is not working when i'm following exactly what doc says. Doc: https://docs.solidjs.com/Idiomatic way to handle API route errorsHi folks, Consider the following API route, using Solid Start: ``` export async function GET() { "Cannot call server function outside of a request" in onRequest middlware hookThis doesn't happen all the time. But happens.What do you recommend for drag and drop capabilities?I am creating an app using tauri and solid for my frontend. And am wanting to have the ability to drAdding Auth to Solid-Start, need some pointersFirst, sorry, this might be a little more generic than just Solid, but I've created my Solid Start aRouter brakes cssCode that works: ```js ...(index.tsx) const root = document.getElementById('root'); if (import.metacreateShortcut callbacks fire even if a textinput has focusI'm making a todo app which has vim motions for navigation. When I hit 'j' or 'k' i'd like these keyRemoving element from store array doesn't remove rendered itemsHi, i need help with this. I have a store that is shared in a context with some helper functions. <Index> with storesHello there, I'm building an application where I have a store defined in a separate non-component fiCan't find replace attribute on <Navigate />This is basically my code, I am trying to check if the user is authenticated, if not then redirect tSolid-CLI won't create any projectWhen creating using `node` (either via `npx` or `bunx`) the CLI fails simply stating 'something wentcreateEffect is reactive, JSX isn't``` export const SavedLineView = (props: { loading: Accessor<boolean> }) => { createEffect(() => {Restricte route by user role, possibly a middleware?Hello, I would appreciate some assistance from more experienced web developers, if possible. My issNavigating with A from and to dynamic route doesn't re-render.I have a dynamic route `routes/post/[postid].tsx`. Within this route I have (simplified) ```tsx consIs it possible to get createAsync to revaluate/ refetch data like createResource?I see the example [here](https://github.com/solidjs/solid-router?tab=readme-ov-file#createasync) but[solved] Can't use `@solidjs/router` in external package for SolidStartI'm trying to write a library for my SolidStart project & need to use the `A` component exported froSeems like I found a JSX bugAs long I know, you can add up variables and raw text inside a tag, something like: `<p>{myVar} peop