Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import ReactDom from 'react-dom';
- const totalColor=40;
- const Box=(props)=>{...}
- class RandomColorApp extends React.Component{
- constructor(props){
- super(props);
- const boxes = new Array(totalColor).fill().map(this.randomColor,this);
- this.state={boxes}
- setInterval(()=>{
- const randomIndex1=Math.floor(Math.random()*3)
- const randomIndex2=Math.floor(Math.random()*3)
- if(randomIndex1!==randomIndex2){
- console.log(randomIndex1,randomIndex2)
- }
- },1000);
- }
- randomColor(){...}
- render(){...}
- }
- RandomColorApp.defaultProps={colors:[...]}
- ReactDom.render(<RandomColorApp/>,document.getElementById('app'));
Add Comment
Please, Sign In to add comment