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

Reactivity rule shouldn't warn when using props.initial* to initialize something else #12

Closed
joshwilsonvu opened this issue Mar 25, 2022 · 0 comments
Assignees

Comments

@joshwilsonvu
Copy link
Collaborator

Describe the bug

It's a somewhat common pattern in React and Solid to initialize a signal/state with the value of a prop. Given that props change over time, making this normally unsafe, a pseudo-standard has emerged to communicate that certain props are intended to be used for this purpose: prefixing them with "initial".

The reactivity rule should catch these cases and suppress the usual "The reactive variable 'props' should be used in a tracked scope" message.

To Reproduce
To reproduce the behavior:

function Component(props) {
  const [count, setCount] = useSignal(props.initialCount);
  return <div>{count()}</div>;
}

Expected behavior
The above snippet shouldn't warn.

Desktop (please complete the following information):

  • OS: Mac OS 11
  • Output of node --version: v16.13.0
  • Output of npm list eslint-plugin-solid/yarn why eslint-plugin-solid: v0.4.4
  • Output of npm list eslint/yarn why eslint: eslint@8.4.1
@joshwilsonvu joshwilsonvu self-assigned this Mar 25, 2022
joshwilsonvu added a commit that referenced this issue Mar 25, 2022
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

No branches or pull requests

1 participant