score:1
Accepted answer
class component extends react.component {
render() {
return (
<>
<div classname="div1"></div>
<div classname="div2"></div>
{this.state.showdiv3 ? <div classname="div3"></div> : null}
</>
);
}
}
the component
itself will re-render (the render
function will be called) because of setstate
call.
for the components it renders, by default (props shallow comparison) only div3
will re-render (remount), see reconciliation.
if you switch the divs with custom components, you can memoize them by having a custom props comparison function (check react.memo
/react.purecomponent
/shouldcomponentupdate
).
Source: stackoverflow.com
Related Query
- react router how can I render only the component in his route whiout the others?
- React Hooks Error: Hooks can only be called inside the body of a function component
- React setState can only update a mounted or mounting component
- Does React render the WHOLE component if only one part of the component changed?
- Only render a react component when I on submit from a form
- React + Antd + Rollup Component Library "Error: Invalid hook call. Hooks can only be called inside of the body of a function component"
- React Hooks can only be called inside the body of a function component
- React 17.0.1: Invalid hook call. Hooks can only be called inside of the body of a function component
- Receiving error - Hooks can only be called inside of the body of a function component when implementing React Spring basic example
- How to render component only once in React Native
- How can I get d3 in a React component to render in a Jest snapshot
- React useEffect calls API too many time, How can I limit the API call to only once when my component renders?
- How can I allow only a single instance of a React component to be present?
- React Hooks Mobx: invalid hook call. Hooks can only be called inside of the body of a function component
- TSparticles React render particles only inside component
- How can I use useEffect in React to run some code only when the component first mounts, and some other code whenever an event occurs (repeatedly)?
- React setstate can only update a mounted or mounting component -- on rerender
- How can you render a react component using dynamic name?
- How to render React (with Redux) component only when props are received?
- React Warning: Can only update a mounted or mounting component
- How can I get a component to render as a parent of protected routes in react router dom?
- React useHistory: Hooks can only be called inside the body of a function component
- How can I render a component in React to 2 different components?
- how to change the style of only one react component that is being render through .map() when the component is clicked
- Invalid hook call. Hooks can only be called inside... how to fix this maintaining the react class component
- How can I render the position of nodes in a React component tree?
- React - setState(...): Can only update a mounted or mounting component
- React render component only for few seconds
- Getting React error: "setState(...): Can only update a mounted or mounting component" ONLY with Child Component
- Can I create a condition to render an React component / element?
More Query from same tag
- Trying to target each image on hover not all at once
- react-datetime dropdown has missing styles(css)
- ReactJS - setState() is not updating
- TypeError: Cannot read properties of undefined (reading 'property')
- Arrays - Javascript - filter array of objects using input search
- Create-react-app - how does index.html read React application code?
- getting error : Hooks can only be called inside of the body of a function component
- Avoid declaring large object in getDefaultProps prior to an event
- How to use scss variables in create react app?
- Stuck at Whitescreen after building Ionic React android app
- How do i call function in functional component - ReactJs
- Redux reducers as pure functions
- Passing Multiple Attributes to a Component
- Currency formatting in React / Javascript
- React-Native - Change style of a component programmatically (no click)
- How to fix "TypeError: Cannot read properties of undefined (reading 'useSystemColorMode')"
- [SPLoaderError.loadComponentError]: ***Failed to load component
- componentDidMount, getCurrentPosition delay
- How to check for null values and replace it if the object?
- ReactJs - Why wont child event change state of parent?
- Use different loader in Webpack depending on from where I'm importing
- How to extend type union props to a react class component?
- React - Insert material-table Actions in the First and Last Column
- ReactDOM to render multiple elements using the same class at ones?
- Rerender is not triggered when changing the props
- How can I play an audio when a component is mounted on React?
- Concatenating a prop onto an Object.assign
- React and CSS gauge progress. SVG circular path length
- Adding a custom button to DatePicker in material-ui
- Make React Material-UI Fab Button to stick to a position on the screen