class FormWidget extends Component {
state={
isFormVisible: false,
};
handleButtonClick = () => {
this.setState(prevState => ({
isFormVisible: !prevState.isFormVisible,
}));
}
render() {
const { isFormVisible } = this.state;
const buttonText = isFormVisible ? 'Hide form' : 'Show form';
return (
<Wrapper>
<Button onClick={this.handleButtonClick}>
{buttonText}
</Button>
<Form isVisible={isFormVisible} />
</Wrapper>
)
}
}
class TaskOutput extends Component {
render() {
var list = [];
for (var i = 0; i < localStorage.length; i++) {
const list = JSON.parse(localStorage.getItem(localStorage.key(i)))
list .push(
<div className={'task'+i}>
<h1>{list['title']}</h1>
<p>{list['description']}</p>
</div>
)
}
return <div>list</div>;
}
}
const array = [{ name: 'John', age: 32}];
const element = { name: 'Sally', age: 25 };
const newArray = [ ...array, element ];
// => [{ name: 'John', age: 32}, { name: 'Sally', age: 25 }]