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

redux-toolkit-helpers

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-toolkit-helpers

redux-toolkit helpers

1.0.3
latest
Source
npm
Version published
Weekly downloads
3
-70%
Maintainers
0
Weekly downloads
 
Created
Source

Redux Toolkit Helpers

Some useful functions against a boilerplate

createSliceReducer

createSlice({
  initialState: {
    name: 'George'
  },
  reducers: {
    setName: createSliceReducer('name')
  }
})

similar to

createSlice({
  initialState: {
    name: 'George'
  },
  reducers: {
    setName: (state, action) => ({
      ...state,
      name: action.payload
    })
  }
})

createSliceSelector

createSlice({
  initialState: {
    name: 'George'
  },
  selectors: {
    selectName: createSliceReducer('name')
  }
})

similar to

createSlice({
  initialState: {
    name: 'George'
  },
  selectors: {
    selectName: (state) => state.name
  }
})

createSliceState

createSlice({
  ...createSliceState(initialState, keys)
})

similar to

createSlice({
  initialState: {
    name: 'George'
  },
  reducers: {
    setName: (state, action) => ({
      ...state,
      name: action.payload
    })
  },
  selectors: {
    selectName: (state) => state.name
  }
})

the keys argument points to all the keys in the state object

Keywords

redux

FAQs

Package last updated on 28 Jan 2025

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