Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Using RecoilRoot via npm #2306

@sky8196

Description

@sky8196

env:
"react": "^18.2.0"
"recoil": "^0.7.7"

The recoilWrapped function is encapsulated and exported in an npm package as follows:
export default function recoilWrapped<T extends JSX.IntrinsicAttributes>(WrappedComponent: (props: T) => JSX.Element) { return (props: T) => { return ( <RecoilRoot> <WrappedComponent {...props} /> </RecoilRoot> ); }; }

This function is used in other projects by importing it from the npm package:
import recoilWrapped from '@my-npm';
recoilWrapped(App);

Under normal circumstances, switching routes would result in a state reset. However, when using recoilWrapped, all other features of Recoil operate as expected, except that the state does not get reset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions