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

Missing reactivity of HydrateAtoms #9

Open
rtritto opened this issue Sep 25, 2024 · 1 comment
Open

Missing reactivity of HydrateAtoms #9

rtritto opened this issue Sep 25, 2024 · 1 comment

Comments

@rtritto
Copy link
Contributor

rtritto commented Sep 25, 2024

With the original implementation (https://jotai.org/docs/guides/initialize-atom-on-render), I created:

// HydrateAtoms.tsx
import type { Component, JSXElement } from 'solid-js'
import { useHydrateAtoms } from 'solid-jotai/utils'

/** @doc https://jotai.org/docs/guides/initialize-atom-on-render */
const HydrateAtoms: Component<{
  initialValues: Parameters<typeof useHydrateAtoms>[0]
  children: JSXElement
}> = (props) => {
  // initialising on state with prop on render here
  useHydrateAtoms(props.initialValues)
  return props.children
}

export default HydrateAtoms

Using eslint-plugin-solid, I get:

  11:10  warning  The reactive variable 'props.children' should be used within JSX, a tracked scope (like createEffect), or inside an event handler function, or else changes will be ignored  solid/reactivity

How should it be fixed?

@rtritto
Copy link
Contributor Author

rtritto commented Sep 26, 2024

This can be fixed with:

- return props.children
+ return <>{props.children}</>

Is it correct?

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