🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

store-context

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

store-context

[GitHub Example](https://github.com/emreyilmazin/store-context-example)

0.2.0
unpublished
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Example

GitHub Example

StoreContext vs. Redux

Advantages

  • Simple than Redux.

  • Easy to use.

  • More than one store in one page.

Disadvanteges

  • All components are rerendered when any component uses the store (in the same scope of context).

Functions

store = ()

Get all lists of the models.

get = (model: string, predicate: func)

Get items from store which are consistent with the predicate function.

add = (model: string, item: JSonObject)

Add item into store into the set which model name is given.

remove = (model: string, predicate: func)

Remove item(s) from store which are consistent with the predicate function.

clear = (model: string default null)

Clear a set which model name is given. If model is null, then clears all store.

Usage

Main.js

import { StoreProvider } from "store-contet";

const Main = (props) => {
//...
  return
//...
    <StoreProvider>
      <OtherElements />
    </StoreProvider>
//...

OtherElements.js

import { useStore } from "store-contet";
//...
const OtherElements = (props) => {
//...
  const { get, add, remove, clear } = useStore();
//... Do Work

Keywords

react

FAQs

Package last updated on 01 Feb 2022

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