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

[Content]: #909

Closed
chasingtheflow opened this issue Oct 1, 2024 · 0 comments · Fixed by #961
Closed

[Content]: #909

chasingtheflow opened this issue Oct 1, 2024 · 0 comments · Fixed by #961
Assignees

Comments

@chasingtheflow
Copy link

📚 Subject area/topic

/concepts/signals.mdx

📋 Page(s) affected (or suggested, for new content)

https://docs.solidjs.com/concepts/signals
https://docs.solidjs.com/reference/basic-reactivity/create-signal

📋 Description of content that is out-of-date or incorrect

I found it pretty confusing that on the final example of this page, what should be a simple counter example, uses a form of passing a function to setCount which is not explained anywhere prior being used in the example:

function Counter() {
  const [count, setCount] = createSignal(0);
  const increment = () => setCount((prev) => prev + 1); // this line confused me

  return (
    <div>
      <span>Count: {count()}</span> {/* Updates when `count` changes */}
      <button type="button" onClick={increment}>
        Increment
      </button>
    </div>
  );
}

Reading the docs from createSignal I can see that there is a form of the setter which is a callback function however even on the createSignal doc that syntax for the setter is not explained very explicitly.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

n/a

@chasingtheflow chasingtheflow added the pending review Awaiting review by team members. label Oct 1, 2024
@LadyBluenotes LadyBluenotes removed the pending review Awaiting review by team members. label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants