I am creating a small application using response.js. I consider "performance" excessive.
So, I have a simple child component called "Spinner". My goal is to ensure that this component is never updated.
Here is my component:
import React, {PureComponent} from 'react'; export default class Spinner extends PureComponent { render() { return ( <div className="spinner"> <div className="bounce1"></div> <div className="bounce2"></div> <div className="bounce3"></div> </div> ) } }
During re-rendering with "response-addons-perf" the component always renders, I use PureComponent because I want this component to be displayed only once, I read that I can use immutable details, but I donβt know how to do it.
If I like it:
componentDidMount() { this.renderState = false; } shouldComponentUpdate(nextProps, nextState) { return (this.renderState === undefined) ? true : this.renderState; }
This is a render only once, but I believe there is a better way.
How to avoid reprocessing? or maybe how can I make an immutable props?
source share