Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import './App.css';
- class App extends React.PureComponent {
- constructor() {
- super();
- this.state = {
- count: 0,
- obj: {
- key1: 0,
- }
- };
- }
- componentDidUpdate(){
- console.log('App: component updated');
- }
- clickHandler = () => {
- const tempObj = {
- key1: 0,
- };
- this.setState({
- count: 0,
- obj: tempObj,
- });
- }
- render() {
- return (
- <div className='container'>
- <div className='top-button'>
- <button onClick={this.clickHandler}>`Default: ${this.state.count}`</button>;
- </div>
- <Child />
- </div>
- );
- }
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment