Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react-dom.development.js:86 Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead.

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";

import App from "./App";

const rootElement = document.getElementById("root");
const root = createRoot(rootElement);

root.render(
  <StrictMode>
    <App />
  </StrictMode>
);
Comment

ReactDOM.render is no longer supported in React 18

// Before
import { render } from 'react-dom';
const container = document.getElementById('app');
render(<App tab="home" />, container);

// After
import { createRoot } from 'react-dom/client';
const container = document.getElementById('app');
const root = createRoot(container);
root.render(<App tab="home" />);
Comment

ReactDOM.render is no longer supported in React 18

import * as ReactDOMClient from 'react-dom/client';
import App from 'App';

const container = document.getElementById('app');

// Create a root.
const root = ReactDOMClient.createRoot(container);

// Initial render: Render an element to the root.
root.render(<App tab="home" />);

// During an update, there's no need to pass the container again.
root.render(<App tab="profile" />);
Comment

ReactDOM.render is no longer supported in React 18

import * as ReactDOM from 'react-dom';
import App from 'App';

const container = document.getElementById('app');

// Initial render.
ReactDOM.render(<App tab="home" />, container);

// During an update, React would access
// the root of the DOM element.
ReactDOM.render(<App tab="profile" />, container);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery if checkbox checked 
Javascript :: jquery video play 
Javascript :: javascript add event listener to all input 
Javascript :: check window resize javascript 
Javascript :: if media query jquery 
Javascript :: align text into center of container react native 
Javascript :: heroicons nextjs 
Javascript :: js remove dollar sign from string 
Javascript :: items in center in native 
Javascript :: round till 2 digit in jquery 
Javascript :: if (!firebase.apps.length) { firebase.initializeApp({}); }else { firebase.app(); // if already initialized, use that one } 
Javascript :: get id in jquery 
Javascript :: electron remove cors 
Javascript :: show 5 entries in datatable 
Javascript :: javascript preload images 
Javascript :: node js list all installed modules 
Javascript :: jest expect async function to throw error 
Javascript :: javascript disable enter key 
Javascript :: create random hex in node 
Javascript :: jquery ajax post form 
Javascript :: set padding jquery 
Javascript :: check if array javascript 
Javascript :: Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. 
Javascript :: split array into chunks 
Javascript :: bubble sort javascript 
Javascript :: reactdom is not defined 
Javascript :: toggle bootstrap modal with jquery 
Javascript :: jquery avoid enter submit 
Javascript :: js remove duplicates from array 
Javascript :: post antiforgerytoken jquery 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =