Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected 2 arguments on createEffect #1

Open
grappleware opened this issue Aug 22, 2021 · 1 comment
Open

Expected 2 arguments on createEffect #1

grappleware opened this issue Aug 22, 2021 · 1 comment
Labels
good first issue Good for newcomers

Comments

@grappleware
Copy link

TypeScript complains that createEffect should have 2 arguments. I believe the following should work without issue:

const [someSignalValue, setSomeSignalValue] = createSignal("foo");

createEffect(() => { 
  console.log(someSignalValue());  // will log "foo"
});

However, the type definition says that there should be a second argument for a value. I'm not sure why this second argument is required or even what it does. Is it a dependency? And if so, shouldn't it be optional since someSignalValue() is automatically tracked?

Maybe I'm misunderstanding. Thanks!

@ryansolid
Copy link
Member

I didn't actually do the typing for this repo, it was community driven and admittedly I haven't used this in a TS based project yet. If it has a type error with the 2nd argument missing that sounds like a bug with the types. The signatures should really be exporting same types as the main Solid repo.

@ryansolid ryansolid added the good first issue Good for newcomers label Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants