0

I am new to ReactJS. This is my first code where I am trying to render two components. I am not getting any error but HTML part is not coming up. DOM is empty. What is wrong here? --

import React from 'react';
import ReactDOM from 'react-dom';

class First extends React.Component{
    render(){
        return (
            <h1>it is about how to render two component. it is first component</h1>
        )
    }
}

class Second extends React.Component{
    render(){
        return (
            <h1>it is about how to render two component. it is second component</h1>
        )
    }
}

class all extends React.Component{
    render(){
        return(
            <section><First /><Second /></section>
        )
    }
}

ReactDOM.render(<all />,document.getElementById('root'));
3
  • Have you put a <div id="root"></div> in your view ? Commented Apr 16, 2017 at 12:37
  • Yes. This is my HTML - Commented Apr 16, 2017 at 12:39
  • <code> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> <title>React App</title> </head> <body> <div id="root"></div> </body> </html> </code> Commented Apr 16, 2017 at 12:40

1 Answer 1

2

In jsx component names starting with lowercase are considered to be HTML elements.

Changing all to All should work fine.

Please refer the answer, ReactJS component names must begin with capital letters?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.