Created
October 9, 2015 01:36
-
-
Save stones/b6c6b3b8ac2a6eee4f98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Attempting to pass data from 1 child to a separate child of the one parent. | |
// Is this retarded ? | |
class Workspace extends Component { | |
state = {current: 'test'}; | |
setCurrentState(component) { | |
this.setState({current: component.props.data.title}); | |
} | |
render() { | |
return ( | |
<div className="workspace" id="Workspace"> | |
{this.props.components.map((component, index) => { | |
return ( | |
<WorkspaceComponent data={ component } key={component.objectid} setCurrent={ this.setCurrentState.bind(this) }/>); | |
})} | |
<AttributeEditor current={this.state.current }/> | |
</div> | |
); | |
} | |
} | |
// Component | |
class WorkspaceComponent extends Component { | |
handleClick() { | |
this.props.setCurrent(this); | |
} | |
render() { | |
return ( | |
<div><button onClick={this.handleClick.bind(this)}>edit</button></div> | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment