npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nebula-note/redux-hooks

v1.0.6

Published

Simplify Redux usage: no actions, no reducers, only hooks.

Downloads

563

Readme

@nebula-note/redux-hooks

npm version

English | 中文文档

@nebula-note/redux-hooks is a lightweight solution for state management fully driven by hooks, built on top of Redux, React-Redux, and @reduxjs/toolkit. No actions, no reducers, just hooks.

Installation

npm i @nebula-note/redux-hooks 

or

 yarn add @nebula-note/redux-hooks

Configure Store

The parameters accepted by configureStore are the same as those in @reduxjs/toolkit configureStore. If your project is already using @reduxjs/toolkit, it can be easily switched over.

import { configureStore } from '@nebula-note/redux-hooks';
const store = configureStore();

Usage


The usage of useRedux is similar to React’s useState, but it includes an additional parameter for the state name. In the code below, REDUX_KEY corresponds to the state name in the Redux store, equivalent to the name parameter in @reduxjs/toolkit’s createSlice. By using the same REDUX_KEY, you can easily share state data across different pages or components.

import { useRedux } from '@nebula-note/redux-hooks';

const REDUX_KEY = 'exampleReduxName';
type ExampleState = {
    count:number
}

export const useExampleRedux = () => {
     const { state, setState } = useRedux<ExampleState>(REDUX_KEY, {count:0});
     
     const handleAdd = () => {
        setState(state.count + 1);
     }
     
     const handleReduce = ()=>{
        setState(state.count - 1);
     }
        
     return(
        <div style={{display:'flex'}}>
            <button onclick={handleAdd}>+</button>
            <div>{state.count}</div>
            <button onclick={handleReduce}>-</button>
        </div>
     )
}

Methods and Properties

Here are the methods and properties provided by useRedux:

state

State data

getStateSync: () => SliceType

Return the latest state value in Redux

setState: (payload: SliceType) => void

Set the state value in Redux

setStateSync: (payload: SliceType) => void

Set the state value in Redux synchronously, which is equivalent to setState.The difference is that after using setStateSync, you can use getStateSync to get the latest state.

updateState(payload: Partial<SliceType>)=> void

Update the state value in Redux, and the state value will be merged with the previous state value.The parameter is partial state content. It is particularly important to note that for Array properties, updateState will not merge the Array properties but will directly overwrite the corresponding properties in Redux with the provided data.

updateStateSync(payload: Partial<SliceType>)=> void

Like updateState, after the call is completed, you can use getStateSync to retrieve the latest state data.

take:(actionType: "setState" | "updateState") => Promise<() => void>

This method is used to listen for changes in the submission state of an action. It returns a promise, which is resolved after the action is executed, and it returns a function to cancel the listener.


const takeHandle = take('setState');
takeHandle.then((offTake) => {
  console.log('State updated');
  offTake();
})

updateState({dataList: resp.data, fetchStatus: 'Success'});

takeOnce: (actionType: "setState" | "updateState") => Promise

Similar to the take function, but it only executes once. After calling, it returns a promise object, and when resolved, the returned content is empty.