Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // parent
  2.  
  3. {this.state.files.map((file, index) => (
  4.     <Image
  5.       onColorChange={(color) => this.onColorChange(color, index)}
  6. )}
  7.  
  8. onColorChange = (color, index) => {
  9.     this.setState({
  10.         files: this.state.files.map((file, i) => {
  11.             if (index !== i) return file;
  12.             return {
  13.                 ...file,
  14.                 color,
  15.             };
  16.         }),
  17.     });
  18. }
  19.  
  20. // image
  21.  
  22. onChange(color) {
  23.   this.props.onColorChange(color)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement