I have declared a const and also included in the render method of component but still cant find that in the rendered html.
The contents of first component are correctly getting rendered, but I am getting empty tag in the html.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import FirstComponent from './FirstComponent'
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
const abc =(props)=>(
<h1>
Hello, {formatName(user)}!
</h1>)
;
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<FirstComponent val="hello"/>
<abc/>
</div>
);
}
}
export default App;
Where am i going wrong with this?
I made abc as Abc and able to see the contents on html.(as per naming conventions of React Component)
But again , I can see below statement : const element = ; on https://reactjs.org/docs/introducing-jsx.html.
Is it like if it starts from a caps letter then will work fine , but if small then I have to explicitly add it using ReactDom.render.
PS:Sorry for such a navie question, but I am a react newbie.