Gathering detailed insights and metrics for react-context-store
Gathering detailed insights and metrics for react-context-store
Gathering detailed insights and metrics for react-context-store
Gathering detailed insights and metrics for react-context-store
A two way binding solution that uses React context as a storage mechanism
npm install react-context-store
Typescript
Module System
Node Version
NPM Version
TypeScript (99.55%)
JavaScript (0.35%)
Shell (0.09%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
857 Commits
2 Watchers
16 Branches
3 Contributors
Updated on Jul 16, 2025
Latest Version
1.1.1
Package Id
react-context-store@1.1.1
Unpacked Size
102.25 kB
Size
10.89 kB
File Count
42
NPM Version
7.12.1
Node Version
16.13.0
Published on
Oct 13, 2022
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A two way binding mechanism that uses React context as a storage machanism.
For small to medium sized apps I found redux to be a bit heavy for what it achieved. In reality, most of the time I want to create a simple website that blocks the form submit as a network call is being processed.
There are a few types of store hooks both of which return the current store contents and the available modifiers.
All come with some basic modifiers:
They also have the same states:
The useIndexableContextStore
and useIndexableStatefulContextStore
have additional update factories that allow for creating functions that manipulate individual items:
The following documentation has been copied out of a test case. If you find that it's not working, please check the test case. This example is an array but you can also use maps, or store a non-indexable type.
First create the context store
1import React, { PropsWithChildren } from "react"; 2 3import { 4 ContextStore, 5 getNotImplementedPromise, 6 useIndexableContextStore, 7} from "react-context-store"; 8 9export type Item = { 10 id: number, 11 name: string, 12}; 13 14type ContextStoreData = Array<Item>; 15 16export type RefreshAllParams = void; 17export interface ContextValue extends ContextStore<ContextStoreData> { 18 refreshAll: (params: RefreshAllParams) => Promise<ContextStoreData>; 19} 20 21const defaultValue: ContextValue = { 22 data: [], 23 refreshAll: getNotImplementedPromise, 24 state: "unsent", 25}; 26 27export const Context = React.createContext(defaultValue); 28export type ProviderProps = PropsWithChildren<{}>; 29 30export function ApiProvider(props: ProviderProps) { 31 const { children } = props; 32 const [contextValue, { useUpdateFactory }] = useIndexableContextStore( 33 defaultValue 34 ); 35 36 const refreshAll = useUpdateFactory({ 37 action: (params: RefreshAllParams) => { 38 return fetchResults(params); 39 }, 40 }); 41 42 return ( 43 <Context.Provider 44 value={{ 45 ...contextValue, 46 refreshAll, 47 }} 48 > 49 {children} 50 </Context.Provider> 51 ); 52}
Somewhere in your app, setup the shared provider
1import { ApiProvider, Context } from "../context"; 2import { List } from "./component"; 3 4export function App() { 5 return ( 6 <ApiProvider> 7 <List /> 8 </ApiProvider> 9 ); 10}
And finally consume the context
1import { ApiProvider, Context } from "../context"; 2 3export function List() { 4 const { data, refreshAll, state } = useContext(Context); 5 6 useEffect(() => { 7 refreshAll(); 8 }); 9 10 switch (state) { 11 case "error": 12 return <div>Oh no!</div>; 13 case "success": 14 return ( 15 <div> 16 <ul> 17 {data.map((item) => { 18 const { id, name } = item; 19 return <li key={id}>{name}</li>; 20 })} 21 </ul> 22 </div> 23 ); 24 default: 25 return <div>Loading</div>; 26 } 27}
For more examples, take a look at our extensive testing suite.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
28 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 8
Details
Reason
8 existing vulnerabilities detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morereact-context-hooks-store
A simple global store based on React Context and Hooks
react-context-api-store
Seemless, lightweight, state management library that supports async actions and persistent states out of the box. Inspired by Redux and Vuex. Built on top of React's context api.
@snolly/context-store
Redux like store with the ability to save data to persistent storage
@fishbot/store-context
State Management with React Context and Hooks