JavaScript React Basics First Steps in React Render an Element

Steven mudie
Steven mudie
5,019 Points

How old is this video? ReactDom.render() doesn't work. although i got it to show by placing title in function App()

function App() { return ( title ); }

export default App;

i am using npx create-react-app though

1 Answer

Dane Parchment
Dane Parchment
9,745 Points

ReactDom.render() definitely still works. Are you sure you have imported it into your file?

ReactDOM.render(element, container[, callback])

Above is the syntax for the method, make sure you are at least providing an element (Component) and a containing element to place that component in. If you are using create-react-app, then the index.js file should also be using the ReactDom.render() method.

Like so:

ReactDom.render(<App />, document.getElementById('root'));