react redux in functional component code example
Example 1: implementation of redux in functional component
import React from 'react'
import { useSelector } from 'react-redux'
export const CounterComponent = () => {
const counter = useSelector(state => state.counter)
return <div>{counter}</div>
}
Copy
Example 2: useDispatch()
useDispatch({ type: '', playload });
Example 3: useSelector
const result: any = useSelector(selector: Function, equalityFn?: Function)
Copy