Redux: Fetching Data on Route Change

Share this video with your friends

Send Tweet

We will learn how to fire up an async request when the route changes.

Hang
Hang
~ 8 years ago

Would this following achieve the same thing with the same performance as the componentDidUpdate part? componentWillReceiveProps(nextProps) { if(this.props.filter !== nextProps.filter) { fetchTodos(nextProps.filter).then(todos => ...) } }

Federico Garcia
Federico Garcia
~ 7 years ago

Could you explain when to use componentWillReceiveProps and when componentDidUpdate? In every tutorial I see, people always use componentWillReceiveProps...

John
John
~ 7 years ago

Regarding the 'Link' component found within 'FilterLink', the 'All' link was not functioning. In order to get it to work I needed to have filter = '/' instead of an empty string when the conditional is true:

filter === 'all' ? '/' : filter (edited filter = '/')

Vs.

filter === 'all' ? '' : filter (original filter = '')

Link Component below,

Link to={filter === 'all' ? '/' : filter} activeStyle={{ textDecoration: 'none', color: 'black', }} > {children} Link

Srikanth  Dasari
Srikanth Dasari
~ 6 years ago

hi,

github link is broken, can you please add it?