question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Responsive Split causes re-render & re-fetch of data

See original GitHub issue

Hello!

I’ve encountered a problem using Split.

Wrapping a component, <C1 />, inside a <Split onResponsive={this._onResponsive.bind(this);}></Split> causes C1 to unmount and then remount(causing me to fetch data two times in componentWillMount) since _onResponsive updates the responsive-state & if the menu should be shown or not.

Do you have any solution on how to do this without re-fetching data? I want the responsive menu, but i’d like to avoid fetching more data.

I think this is more of a general React-problem rather than Grommet but i’m wondering if anyone has encountered the issue and how you solved it? I’m thinking of fetching data when a react-router route is changed, but that’s not optimal IMO.

I followed the docs-example but the DocsSplit doesn’t fetch data so it’ll only cause a re-render.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
alansouzaticommented, Mar 22, 2016

yeah yeah, thanks for chiming in.

0reactions
linde12commented, Mar 26, 2016

@alansouzati Can you have a look at this diff when you have time?

It solves the problem of the components remounting(thus refetching data, resetting state etc.) but introduces another problem when Split is used with 3 or more children.

The flex breaks since the children are wrapped in two separate div elements in order to hide/show them at the correct width.

I just thought that maybe you’d have some better way of solving this after seeing the merge? Or if you’ve got some css-magic to make the flex work anyway?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does simply fetch data cause React Component to rerender
I could see the reason being that in other posts others use useState as well to get the data and change the state...
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
In this tutorial, you'll handle asynchronous data in React by ... When you do, the browser will refresh and render the basic components....
Read more >
React re-renders guide: everything, all at once - Developer way
There are four reasons why a component would re-render itself: state changes, ... Preventing Context re-renders: splitting data and API.
Read more >
Developing responsive layouts with React Hooks
We are going to use React Hooks to create an elegant and, more importantly, reusable solution to the problem of creating responsive layouts ......
Read more >
How to determine what causes components to rerender
When data changes it will trigger updates on any components that used that data during their previous render. These updates don't happen ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found