davnicwil / react-frontload

Async data loading for React components, on client & server
451 stars 21 forks source link

frontloadConnect not running when navigating #30

Closed tfsjohan closed 5 years ago

tfsjohan commented 5 years ago

I use React Router and have a page with links like /view/1, /view/2. These use the same Frontload-enhanced component. But my frontload function is not run when navigating between pages that use the same component. It does work when navigating to a page that use a different component.

I can see that the component runs componentDidUpdate and props.location.pathname is updated so I don't understand why the frontload function is not run again.

Any ideas what I should do?

davnicwil commented 5 years ago

Hey @tfsjohan

There's a mistake in the docs for frontloadConnect - the onUpdate option is actually default false, not default true. Sorry about that - I'll correct it.

If you set onUpdate true, it should run - can you try that and let me know if it works?

tfsjohan commented 5 years ago

Thanks! That solved the problem. I just had to be more careful when writing new state to not could a infinite loop of updates. :)

davnicwil commented 5 years ago

Great!