Yes, it is perfectly fine to call
React.render multiple times on the same page. Just as you've suggested, the React library itself is only loaded once, but each call to
React.render will create a new component instance independent of any others. (In fact, such a situation is not uncommon on sites that are in the process of transitioning to React, where some portions of the page are generated using
React.render and others are not.)
If you were wondering if it's ok to use ReactDOM.render() multiple times with the same container, the docs say: "If the React element was previously rendered into [the same] container, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React element"
This approach is ok from a page load performance point of view, but there are other downsides and multiple React roots should be avoided if possible.
- Different React roots cannot share context, and if you need to communicate between the React roots, you will need to fall back on global DOM events
- You get less benefit from performance optimizations like time slicing - suspense and async rendering. It's not possible to suspend across React root boundaries
- Use React Portal to render a child into a DOM node of the parent component
- React - use the exact same component instance many times in the DOM
- How can I create a counter as components to use multiple times and create one button to reset all the counter in React JS?
- React won't render multiple fetched API's to the DOM
- Is it OK to use React.render() multiple times in the DOM?
- Is there a way to render multiple React components in the React.render() function?
- React component render is called multiple times when pushing new URL
- Multiple times render in react functional component with hooks
- Render multiple React components into a single DOM element
- How do i use a single render across multiple tests in React Testing Library.?
- React - What is the Best Way to use Multiple createContexts?
- React trying to use .map to populate data from multiple APIs into the same mapped container
- Force remount component when click on the same react router Link multiple times
- Render Same Component With Multiple Paths React Router Dom
- use ES6 .map() on multiple times nested objects for react components
- Testing Library : How to render the same component multiple times without coupling
- Running setInterval() inside React function happens multiple times and increases the amount rapidly over time
- Use a common function to handle change of the multiple array-based similar states on the user click in REACT
- Can we render elements from multiple js files into the root node in React JS?
- Props mix when using the same component multiple times on a page in React
- React - What is meant by 'Do not use HOC’s in the render method of a component. Access the HOC outside the component definition.'?
- Use react component as a child or from within the render function of a React component
- Understanding how/why/when React updates the DOM and how to use it
- React Router v6 : How to render multiple component inside and outside a div with the same path
- Using Matter.js to render to the DOM or React
- How can I use the same React app in multiple locations of the same page?
- Render react component multiple times onClick
- React useEffect hook with empty dependency render multiple times
- react router render component multiple times when refreshing
More Query from same tag
- React array being returned with no data, but there is data within the array with inspect element
- Add the classes after 2 loops on react using map
- How to retrieve data from date in weather api?
- How <Switch> works when it encounters React Components in it?
- Calling an async function inside the if condition of useEffect hook
- Get sum from the nested array of objects
- React-Redux: Why does the fetched data array always have length 1, even if it contains no data?
- ReactJS + Redux: How to trigger a button to open up a Mac Mail/Windows Mail with property email?
- How to explicitly create an optional property in a React component when it is not specificied?
- Getting invalid hook call error in React when I used materidal design bootstrap component in my application
- Is it possible to use bootstrap 4 in a nextjs project by just adding a link stylesheet?
- React Js Handling event button on a column to get row using onClick
- Problems using html-to-image in a React application
- Change only state of clicked card
- React: How to navigate through list in a table by arrow keys without triggering the scrollbar moving up and down?
- using value in useState but when I use it in this.state the switch between tabs not happening
- Executing React method 3 times and performing an action on the 3rd try
- Array in React useState: Problem with performance
- useEffect simulating componentWillUnmount does not return updated state
- How to get address based on lat lang lng in react google map
- React pdf onclick download
- React, redux component does not update on route change
- How to add a new key value to react js state array?
- Why does the new `Pick<T, K extends keyof T>` type allow subsets of `K` in React's `setState()`?
- How to set timeout in Fetch API using react js
- ReactJs print value of input field
- Component Render Issues (Long Read)
- Warning: Failed prop type: The prop `term` is marked as required in `ParentComponent`, but its value is `undefined`
- getByText doesn't find the element
- React router with 2 entry points