I am learning ReactJS, apologies if the question is basic.
I created a component:
import React, { Component } from 'react';
class title2 extends Component {
constructor(props){
super(props);
}
render() {
return (
<div className="shopping-list">
<h1>Shopping List for {this.props.name}</h1>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
);
}
}
export default title2;
I want to render the component "title2" from my main component (App):
import React, { Component } from 'react';
import './App.css';
import title2 from './title2';
class App extends Component {
constructor(props) {
super(props);
this.state = { name2: 'world', };
}
render() {
return (
<div className="App">
Hello {this.state.name2}
{title2}
</div>
);
}
}
export default App;
This, in browser, displays "Hello world", however, it doesn't output anything from the "title2" component, and it doesn't result in error either. How can I solve this?