Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

recoil

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recoil

Recoil - A state management library for React

  • 0.7.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
309K
decreased by-43.29%
Maintainers
4
Weekly downloads
 
Created

What is recoil?

Recoil is a state management library for React applications. It provides a way to manage and share state across components with a minimal API and a focus on performance and scalability.

What are recoil's main functionalities?

Atoms

Atoms are units of state in Recoil. They can be read from and written to from any component. Components that read the value of an atom will re-render when the atom's value changes.

const { atom } = require('recoil');

const textState = atom({
  key: 'textState',
  default: '',
});

Selectors

Selectors are pure functions that transform state. They can compute derived state based on atoms or other selectors. Components that read the value of a selector will re-render when the selector's value changes.

const { selector } = require('recoil');

const charCountState = selector({
  key: 'charCountState',
  get: ({ get }) => {
    const text = get(textState);
    return text.length;
  },
});

RecoilRoot

RecoilRoot is a component that provides the Recoil state context to its descendants. It must wrap the part of your application that uses Recoil state.

const { RecoilRoot } = require('recoil');
const React = require('react');
const ReactDOM = require('react-dom');

function App() {
  return (
    <RecoilRoot>
      <MyComponent />
    </RecoilRoot>
  );
}

ReactDOM.render(<App />, document.getElementById('root'));

Other packages similar to recoil

FAQs

Package last updated on 01 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc