Skip to content

Instantly share code, notes, and snippets.

@iswanj
Last active March 24, 2016 06:29
Show Gist options
  • Save iswanj/b8951d4212e40ccbbf28 to your computer and use it in GitHub Desktop.
Save iswanj/b8951d4212e40ccbbf28 to your computer and use it in GitHub Desktop.
Reactjs import/export component (ES6)
import React from 'react';
class Button extends React.Component {
render() {
const { label, onClick } = this.props;
return(
<div>
<button onClick={onClick}>{label}</button>
</div>
);
}
}
export default Button;
import React from 'react';
import Button from './Button';
import Input from './Input';
class Home extends React.Component {
handleClick(e) {
///
}
render() {
return (
<div>
<Input />
<Button label="Submit" onClick={this.handleClick.bind(this)} />
</div>
);
}
}
export default Home;
import React from 'react';
class Input extends React.Component {
render() {
return(
<div>
<input ref="input" type="text" />
</div>
);
}
}
export default Input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment