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.

Due to the increasing size of the parsers and UIComponents we’re loosing performance. We should investigate what causes the laggy behaviour and then fix it.

e.g. shouldComponentUpdate could help fixing problems with the UI performance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jansulecommented, Oct 31, 2018

We can declare components with simple props and states as PureComponents. These components already call shouldComponentUpdate() with a shallow comparison. This could reduce code.

React.PureComponent is similar to React.Component. The difference between them is that React.Component doesn’t implement shouldComponentUpdate(), but React.PureComponent implements it with a shallow prop and state comparison. https://reactjs.org/docs/react-api.html#reactpurecomponent

This is especially applicable for the input fields. Then, we have to implement shouldComponentUpdate() only for the other components.

0reactions
jansulecommented, Nov 5, 2018

We still have a few unneccessary render() calls, because in some components we are using state and props for the same property (usually a style-subprop). An example can be found in Style component (see code below).

// src/Component/Style/Style.tsx

// default props
interface DefaultStyleProps {
  style: GsStyle;
  locale: StyleLocale;
}

// ...

// state
interface StyleState {
  style: GsStyle;
}

// ...

onNameChange = (name: string) => {
  const style = _cloneDeep(this.state.style);
  style.name = name;
  if (this.props.onStyleChange) {
    this.props.onStyleChange(style);   // <-- calling onStyleChange, which will update this.props.style
  }
  this.setState({style}); // <-- calling this.setState, which will update this.state.style
}

This component is a mixture of a controlled and uncontrolled component. It will be rendered twice due to the calls to onStyleChange and this.setState on the same change event.

I think we should remove the state and let the parent handle the change. This also complies with common react patterns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance Definition & Meaning - Merriam-Webster
1 · the execution of an action · something accomplished : deed, feat ; 3 · the action of representing a character in...
Read more >
Performance Bicycle - Your Next Best Ride
Shop road, mountain & gravel bikes. Huge selection of parts, components & clothing from Specialized, Shimano & more!
Read more >
Performance - Wikipedia
A performance is an act of staging or presenting a play, concert, or other form of entertainment. It is also defined as the...
Read more >
86 Synonyms & Antonyms for PERFORMANCE - Thesaurus.com
Find 86 ways to say PERFORMANCE, along with antonyms, related words, and example sentences at Thesaurus.com, the world's most trusted free thesaurus.
Read more >
Performance Definition & Meaning - Dictionary.com
performance · a musical, dramatic, or other entertainment presented before an audience. · the act of performing a ceremony, play, piece of music,...
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