Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
Created February 20, 2019 06:30
Show Gist options
  • Save nnarhinen/99ac873f0516652d32e1098e61e96f29 to your computer and use it in GitHub Desktop.
Save nnarhinen/99ac873f0516652d32e1098e61e96f29 to your computer and use it in GitHub Desktop.
React hooks + redux-hooks + redux-router-dom + immer-reducer
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