New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-tracked

Package Overview
Dependencies
Maintainers
0
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tracked

State usage tracking with Proxies. Optimize re-renders for useState/useReducer, React Redux, Zustand and others.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
150K
increased by0.76%
Maintainers
0
Weekly downloads
 
Created

What is react-tracked?

react-tracked is a state management library for React that focuses on minimizing re-renders by tracking state usage at the component level. It provides a way to create a global state and ensures that only the components that actually use a piece of state will re-render when that state changes.

What are react-tracked's main functionalities?

Creating a Tracked State

This feature allows you to create a tracked state container. The `createContainer` function is used to create a context provider and a custom hook `useTracked` that can be used to access and update the state.

const { Provider, useTracked } = createContainer(() => useState(0));

Using Tracked State in Components

This feature demonstrates how to use the tracked state in a component. The `useTracked` hook is used to access the state and the state updater function. The component will only re-render when the state it uses changes.

const Counter = () => {
  const [count, setCount] = useTracked();
  return (
    <div>
      <p>{count}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  );
};

Providing Tracked State

This feature shows how to provide the tracked state to the component tree. The `Provider` component created by `createContainer` is used to wrap the component tree, making the tracked state available to all components within the tree.

const App = () => (
  <Provider>
    <Counter />
  </Provider>
);

Other packages similar to react-tracked

Keywords

FAQs

Package last updated on 10 Sep 2024

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