Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript React Basics First Steps in React Render an Element

Steven mudie
Steven mudie
5,523 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
MOD
Dane Parchment
Treehouse Moderator 10,726 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'));