'React not updates component on store changes
I have component with cards. Needs to update it on page changing with Redux store. I understand why code is not working but have no idea how to fix it.
function Cards(props) {
const { beers = [] } = props
const changePage = (newPage) => {
page = newPage
}
let page = store.getState().pages
store.subscribe(() => changePage(store.getState().pages))
return (
<div className='cards'>
<div className='cards__content'>
{beers.slice(page*9, page*9+9).map(beer => <MenuCard name={beer.name} description={beer.brewers_tips} id={beer.id} key={beer.id} />)}
</div>
<Pages amount={Math.floor(beers.length / 9)} />
</div>
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
