I need to dispatch Redux actions inside React custom hook. How do I obtain the store instance to dispatch actions inside the function? I guess useContext should do the trick, but I'm not sure how to actually use it. Here are code examples
export const useValueInput = (oletusArvo) => {
const [value, asetaValue] = useState(oletusArvo)
const [store] = useContext(???)
const onChange = ({target}) => {
asetaValue(target.value)
}
return [
value,
asetaValue,
{
value,
onChange
}
]
}
Upper in the hierarchy I have defined store provider as follows
render() {
return (
<div>
<Provider store={store}>
<ComponentRouter />
</Provider>
</div>
)
}