🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@abdulghani/reduxcontext

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abdulghani/reduxcontext

lightweight redux context setup with provider, useSelector, useDispatch all setup.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Redux Context setup

In this project there's several component you could import to your project to use

  • AppContextProvider default providing context to it's children and specify reducer to use
  • useSelector named function for selecting/get the state value from the context state
  • useDispatch named function for dispatching actions to your context's reducer

Usage

You can use it this way

  // import your deps
  import AppContextProvider from "@abdulghani/reduxcontext";
  import myReducer from "somewhere";

  const App = () => {
    return (
      <AppContextProvider reducer={myReducer}>
        <MyApp/>
      </AppContextProvider>
    )
  }

And you can access the state from your component this way

  // other imports
  import {useSelector, useDispatch} from "@abdulghani/reduxcontext"

  const MyView = () => {
    const state = useSelector(state => state);
    const dispatch = useDispatch();

    useEffect(() => {
      // do something in initial render
      dispatch({ type: "MY_ACTION", data: "SOME DATA" });
    }, [])
  }

Keywords

redux

FAQs

Package last updated on 09 Jan 2020

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