Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. interface State {
  2. leftButtonVisible: boolean,
  3. rightButtonVisible: boolean,
  4. }
  5.  
  6. class ButtonsContainer extends React.PureComponent<{}, State> {
  7.  
  8. public state: State = {
  9. leftButtonVisible: true,
  10. rightButtonVisible: false,
  11. };
  12.  
  13. public updateVisibleButton = () => {
  14. this.setState({
  15. leftButtonVisible: !this.state.leftButtonVisible,
  16. rightButtonVisible: !this.state.rightButtonVisible,
  17. })
  18. }
  19.  
  20. public render() {
  21. return (
  22. <Container>
  23. <Button
  24. data-testid="switchButton"
  25. onClick={this.updateVisibleButton}
  26. type={ButtonType.DEFAULT}
  27. >
  28. Switch visible Value
  29. </Button>
  30.  
  31. <ButtonsWrapper>
  32. <div style={{ flex: 1 }}>
  33. {this.state.leftButtonVisible &&
  34. <Button data-testid="leftButton" type={ButtonType.PRIMARY}>
  35. Left visible!
  36. </Button>
  37. }
  38. </div>
  39.  
  40. <div style={{ flex: 1 }}>
  41. {this.state.rightButtonVisible &&
  42. <Button data-testid="rightButton" type={ButtonType.DANGER}>
  43. Right visible!
  44. </Button>
  45. }
  46. </div>
  47. </ButtonsWrapper>
  48. </Container>
  49. );
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement