Guest User

Untitled

a guest
May 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import './App.css';
  3. import MainTool from './components/Layout/MainTool/MainTool.js';
  4. import Aux from './hoc/Aux.js';
  5.  
  6. class App extends Component {
  7.  
  8. state = {
  9. MainList: [
  10. "GamePlay",
  11. "Visuals",
  12. "Audio",
  13. "Story"
  14. ],
  15. color: "white"
  16. }
  17.  
  18. changeEle = () =>{
  19. this.setState({color : "red"});
  20. }
  21.  
  22. render() {
  23. return (
  24. <Aux>
  25. <MainTool MainList = {this.state.MainList}
  26. change = {this.changeEle}
  27. color = {this.state.color}/>
  28. </Aux>
  29. );
  30. }
  31. }
  32.  
  33. export default App;
  34.  
  35. import React from 'react';
  36. import './MainTool.css';
  37. import CheckBlock from '../../CheckBlock/CheckBlock';
  38.  
  39. const MainTool = props => {
  40. return (
  41. <div className = "mtborder">
  42. <CheckBlock MainList = {props.MainList}
  43. change = {props.change}
  44. color = {props.color}/>
  45. </div>
  46. );
  47. };
  48.  
  49. export default MainTool;
  50.  
  51. import React from 'react';
  52. import './CheckBlock.css';
  53. import Aux from '../../hoc/Aux';
  54.  
  55. const CheckBlock = props => {
  56.  
  57. console.log(props.change);
  58. console.log(props.color);
  59.  
  60. let mainList = [];
  61.  
  62. for(let i = 0; i <= 3; i++)
  63. {
  64. mainList[i] = <li key = {i}
  65. className = "nameBox">{props.MainList[i]}
  66. <div onClick = {props.change}
  67. style = {{backgroundColor: props.color}}
  68. className = "clickBox"></div></li>
  69. }
  70.  
  71. //console.log(dubi());
  72.  
  73. return (
  74. <Aux>
  75. <ul className = "mainList">{mainList}</ul>
  76. <button>Enter</button>
  77. </Aux>
  78. );
  79. };
  80.  
  81. export default CheckBlock;
Add Comment
Please, Sign In to add comment