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.

re-renders are triggered even if the style props aren't changed

See original GitHub issue

Describe the bug When sx remains constant, the component re-renders on both 0.3.x and 0.4.x-rcs

To Reproduce Steps to reproduce the behavior:

  1. Go to https://91hn6.csb.app/ or code

  2. In react-dev-tools enable highlights when a component re-renders

  3. type in the first input box (emotion jsx), see that only the input triggers the highlights

  4. type in the second input box (theme-ui jsx) see that the input triggers highlights even if the sx prop is hoisted out and is a constant object

Expected behavior Ideally, if the value that is passed in to sx doesn’t change, then emotion could also use their caching to not re-render.

Screenshots

Screen Recording 2020-11-25 at 10 58 42 AM

Additional context We probably need to dig into how emotion is able to return the same component if the style stays the same.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
alexanderchancommented, Nov 25, 2020

@atanasster it looks like theme-ui 0.5.0-alpha with emotion 11 doesn’t have the re-render issue so we can probably go without the plugin for now. I’ll keep you posted if I find other cases of re-rendering due to object styles.

0reactions
atanasstercommented, Nov 25, 2020

@alexanderchan - I am a bit behind - do you think we need to incorporate the hoisting in the plugin?

Read more comments on GitHub >

github_iconTop Results From Across the Web

When does React re-render components? - Felix Gerschau
Directly mutating the props object is not allowed since this won't trigger any changes, and React doesn't notice the changes. this.props.user.
Read more >
Component getting re-rendered when props aren't changing
I'm showing a map that is memoized using React. memo(). I want the map to only re-render when the props change, but it...
Read more >
How and when to force a React component to re-render
React automatically re-renders components, but what happens when a component is not updating as expected? Find out what you can do here.
Read more >
dynamically changing a styled component property re-renders ...
The first dom update seem to trigger a full-page re-render (throttle cpu if necessary). Then any further changes to that same property updates ......
Read more >
Debug Why React (Re-)Renders a Component
Each state change in the parent component triggers a re-rendering of the child components even if they did not receive any props.
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