Created
February 20, 2019 06:30
-
-
Save nnarhinen/99ac873f0516652d32e1098e61e96f29 to your computer and use it in GitHub Desktop.
React hooks + redux-hooks + redux-router-dom + immer-reducer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from "react"; | |
import { withRouter } from 'react-router-dom' | |
import { useProductSelectors, useProductActions } from "../redux/actions/products" | |
import Qs from 'querystring' | |
const Products = withRouter(({ location: { search }, history}) => { | |
const actions = useProductActions() | |
const [products] = useProductSelectors(selectors => [selectors.getProducts()]) | |
const i18n = window.i18n | |
const filter = Qs.parse(search.replace(/^\?/, '')) | |
useEffect(() => { | |
actions.fetchProducts(filter) | |
}, [search]) | |
return ( | |
<div> | |
<h2>Products</h2> | |
<p>Content here</p> | |
</div> | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment