Skip to content

Instantly share code, notes, and snippets.

@Lail
Lail / functional_implict.js
Last active March 2, 2017 15:04
Basic Functional Component
const MyComponent = ({ name, quote }) => (
<p>{ `${name} commands ${quote}` }</p>
)
@Lail
Lail / functional_return.js
Last active March 2, 2017 15:04
Functional React Component w/ explicit return
const MyComponent = ({ name, quote }) => {
const myFunction = (name, quote) => {
return `${name} commands ${quote}`
}
return (
<p>{ myFunction(name, quote) }</p>
)
}
@Lail
Lail / createClass.js
Last active March 2, 2017 14:54
Basic React component using React.createClass factory
const MyComponent = React.createClass ({
render: function() {
return <h1>My name is { this.props.name }</h1>
}
});
@Lail
Lail / classExtend.js
Created February 28, 2017 20:01
Simple React class component user extend
class MyComponent extends Component {
render () {
return <h1>My name is { this.props.name }</h1>
}
}
@Lail
Lail / createClassFull.js
Last active March 2, 2017 15:00
Using the React Factory Method
const MyComponent = React.createClass ({
getInitialState: function(){
return { name: ‘Optimus Prime’ };
},
getDefaultProps: function(){
return { quote:’Roll Out!’ }; 
},
@Lail
Lail / extendFull.js
Last active March 2, 2017 15:01
Extending the React Component Class
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = { name: ‘Optimus Prime’ }
this.myFunction = this.myFunction.bind(this)
}
myFunction: function(){
return `${this.state.name} commands ${this.props.quote}`

Keybase proof

I hereby claim:

  • I am lail on github.
  • I am lailsn (https://keybase.io/lailsn) on keybase.
  • I have a public key ASDgKQKYoqzJAcEbRn5eGEw8gH9Sr5aszhDQ8syEyqYPnAo

To claim this, I am signing this object: