Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 605 Bytes

cleanup.md

File metadata and controls

35 lines (28 loc) · 605 Bytes
id title
cleanup
cleanup()

function that dispatches an action to delete the state from redux store. useful when you dont want to persist the state when component unmounted.

function is provided by use-redux-states

cleanup()

Example

import { useEffect } from 'react'
import useReduxState from 'use-redux-states'
const Component = () => {

  const {cleanup} = useReduxState({
    state: {
      state1: 'a',
      state2: 'b'
    },
    path: 'component_state'
  })

  useEffect(() => {
    return () => cleanup()
    /* component_state: undefined */
  }, [])
}