Guest User

Untitled

a guest
Sep 10th, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import React from 'react';
  2. import './App.css';
  3. class App extends React.PureComponent {
  4.  
  5. constructor() {
  6. super();
  7. this.state = {
  8. count: 0,
  9. obj: {
  10. key1: 0,
  11. }
  12. };
  13. }
  14.  
  15. componentDidUpdate(){
  16. console.log('App: component updated');
  17. }
  18.  
  19. clickHandler = () => {
  20. const tempObj = {
  21. key1: 0,
  22. };
  23. this.setState({
  24. count: 0,
  25. obj: tempObj,
  26. });
  27. }
  28.  
  29. render() {
  30. return (
  31. <div className='container'>
  32. <div className='top-button'>
  33. <button onClick={this.clickHandler}>`Default: ${this.state.count}`</button>;
  34. </div>
  35. <Child />
  36. </div>
  37. );
  38. }
  39. }
  40.  
  41. export default App;
  42.  
Advertisement
Add Comment
Please, Sign In to add comment