React Day1
Jul 30, 2022
Creat a Parts
it’s different to component, more than tiny like a cell, and usually for assemble.
const CurrentDate = props => <span>{props.date}</span>;(could be output like this)
<CurrentDate date={Date()} />
Define a Component
Build in class, render html tag, or render another parts/components.
class XXX extends React.Component {Get W.Hsuan’s stories in your inbox
Join Medium for free to get updates from this writer.
constructor(props) {
super(props);
this.state = { isOn: true };
}
render() {
return … ;
}
}Example:
return <h1>Hello World<h1/>
or
return <anotherComponent/>
Output on HTML
render your component itself or give a parents html tag for it.
ReactDOM.render( <XXX/>, document )Example:
( <XXX/>, document.getElementById(‘parents’) )





