class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}class Car extends React.Component {
constructor(props) {
super(props);
this.state = {brand: "Ford"};
}
render() {
return (
<div>
<h1>My Car</h1>
</div>
);
}
}class Todo extends React.Component {
//Setting the initial state of the Component
constructor() {
super();
this.state = {
task: "",
isCompleted: false,
dateCreated: ""
}
}
}class Todo extends React.Component {
constructor() {
super();
this.state = {
task: "",
isCompleted: false,
dateCreated: "",
};
}
// Updating state after Component is mounted
componentDidMount() {
const currentDate = new Date();
const dateString = currentDate.toDateString();
this.setState({dateCreated: dateString});
}
}class Todo extends React.Component {
constructor() {
super();
this.state = {
task: "",
isCompleted: false,
dateCreated: "",
};
}
// Updating state after Component is mounted
componentDidMount() {
const currentDate = new Date();
const dateString = currentDate.toDateString();
this.setState({dateCreated: dateString});
}
}