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

recoilens

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recoilens

The Recoilens provides a custom state logger for Recoil, a state management library for React. It allows you to track changes in a specific atom and display a message as a popup

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Recoilens Recoil Logger Library - RRLL

The Recoilens provides a custom state logger for Recoil, a state management library for React. It allows you to track changes in a specific atom and display a message as a popup.

Installation

To install the Recoil Logger Library, use npm or yarn:

npm install recoilens
# or
yarn add recoilens

Usage

1. Import the Library

import RecoilLogger from "recoilens";

2. Wrap your Application in RecoilRoot

Wrap your application with RecoilRoot to provide the Recoil state context:

import { RecoilRoot } from "recoil";

const App = () => {
  return (
    <RecoilRoot>
      <RecoilLogger value={myAtom} />
      {/* Other components */}
    </RecoilRoot>
  );
};

export default App;

3. Add Atom and Controls

Define your Recoil atom and add controls to interact with it:

import { useRecoilState, atom } from "recoil";

export const myAtom = atom({
  key: "myAtom",
  default: {
    property: 0,
  },
});

const ButtonControls = () => {
  const [currentValue, setCurrentValue] = useRecoilState(myAtom);

  const increaseValue = () => {
    setCurrentValue((prevValue) => {
      const updatedValue = {
        ...prevValue,
        property: prevValue.property + 1,
      };
      return updatedValue;
    });
  };

  const decreaseValue = () => {
    setCurrentValue((prevValue) => {
      const updatedValue = {
        ...prevValue,
        property: prevValue.property - 1,
      };
      return updatedValue;
    });
  };

  return (
    <div>
      <button onClick={increaseValue}>Increase Value</button>
      <button onClick={decreaseValue}>Decrease Value</button>
      <div>Current Value: {currentValue}</div>
    </div>
  );
};

4. Run Your Application

Start your application to see the Recoilens Logger in action.

License

This library is released under the MIT License.

Keywords

FAQs

Package last updated on 06 Dec 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