score:1
Accepted answer
I would not do this, I would recommend looking at the other lifecycle methods here:
https://reactjs.org/docs/react-component.html
For example, shouldComponentUpdate()
, which factors in a boolean value which may prevent re-rendering:
shouldComponentUpdate(nextProps, nextState) {
if (nextState.name != this.state.name)
return false;
return true;
}
Source: stackoverflow.com
Related Query
- Is it ok to change directly the state if we don't want to re-render?
- in a map function, i want to set a state which let me change the background color when i click on a div
- I have many checkbox it render as the description below I want to change the nested value its in blue circle in the pic
- I want to directly call the result value by arithmetic operation on two state values
- How to not change the state at the first render of React component?
- I want to send the state from a component to another component to render it, how to do it without Redux?
- Does change in Props Data Change the state of components or will it render the change?
- I want to change the state of a single book in my react app but it changes state of the whole array
- re render a react component only when the state change
- React Hooks useState changing multiple elements state in one mouseOver function only want to change the moused over one
- I want to change the state value of array while using Redux toolkit
- why Can't change the state in the render method. What is the best place to change the state before calling render method
- What's the better way to change state on every render for number of times
- I want to change the value of the state with the next values from an array
- React Hooks - useEffect fires even though the state did not change
- How to change multiple properties of a state in react (at the same time)?
- On url change I want to re render my component how should I do that
- how to rerender a component when hash change and change the state
- Reactjs how to change the state of a component from a different component
- React hooks change the state on postMessage
- How to change the Redux state based on an Electron menu click?
- React leaflet center attribute does not change when the center state changes
- onChange or onBlur to change the state in ReactJs?
- Why is the DOM not updating with state change in ReactJS?
- Which of these strategies is the best way to reset a component's state when the props change
- Should I be concerned with the rate of state change in my React Redux app?
- What is the best way to implement undo state change (undo store/history implementation) in React Redux
- Change state dynamically based on the external Internet connectivity - React (offline/online)
- Change the state when clicking outside a component in React
- In React componentDidUpdate, can props and state change at the same time?
More Query from same tag
- Compare 2 array key and values in the same object
- React.js and arrow functions vs normal functions
- Pulling / Stretching div on hover over border?
- Instance of reactJs component to render a component
- Type error using react-cool-inview ('RefObject<HTMLElement>' is not assignable to type 'RefObject<HTMLDivElement>')
- What's the maximum memory size of the redux store?
- Styled component not wrapping another styled component
- Pushstate and popstate not working with condtionally rendered components
- Render nextjs page using layout - has already been declared error
- Function outside React class method undefined
- Pass state from a JSX NavBar to a JSX Map in react
- unable to remove react element onclick
- Avoid infinite loop with useEffect hook
- React: Check if key is unique
- How do I prevent (uninstall) TypeScript installing and referencing it's own @types into AppData\Local
- How to compile JSX server side
- How to align react-bootstrap modal relative to the button clicked
- How can I add style to the body element with JSS?
- How setState works with memo in react
- How do you pass in a property when instantiating a React component
- How To Have Multiple Axios inside UseEffect That Doesnt Turn Error?
- unit test stateless component method
- React: triggering method inside HOC component
- MUI DatePicker default textfield cannot be customized with different font color and size
- ReactDOM.findDOMNode() using React.Children child
- Can React Hooks have methods?
- Numbering child elements in ReactJS
- Lifecycle - fetch data only after loading complete
- How do we mock fetch for Redux Async Actions?
- How to update multiple form values with one reducer action?