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
class NeatoComponent extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
foo: this.props.foo, | |
bar: this.props.bar | |
} | |
} | |
render() { |
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
class NeatoComponent extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
foo: this.props.foo, | |
bar: this.props.bar | |
}; | |
} | |
componentWillReceiveProps(nextProps) { |
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
function filterMyArray(filterProperty) { | |
let _ = this.myArray.concat(); // safely copy myArray (which is an array of objects) | |
let filtered = _.filter((i) => { | |
return i.propery === filterPropery | |
}); | |
return filtered; | |
} |
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
class GenericControlledForm extends React.Component { | |
constructor() { | |
super(); | |
this.state { | |
name: '', | |
occupation: '' | |
}; | |
this._onChange = this._onChange.bind(this); | |
} | |
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
let PrettyLoader = (props) => { | |
let style={ 'hidden' : props.loading === true ? true : false }; // Or whatever way you want to toggle the content | |
return <PrettyLoader style={style}>{props.children}</PrettyLoader>; | |
}; |
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
import React from 'react'; | |
import { connect } from 'react-redux'; | |
class PrettyLoader extends React.Component { | |
_show() { | |
// Don't forget that loading can be any data type you want! | |
if (this.props.loading === true) { | |
return ( | |
<div className="loading"> | |
<img src="crazyLoading.gif" /> |
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
class Step1 extends React.Component { | |
constructor(props) { | |
super(props); | |
// Bindings for form fields would go here, | |
// and state would keep track of field input | |
} | |
_validate() { | |
// a sanitized version of state can be passed instead | |
this.props.afterValid(this.state) | |
} |
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
class BasicWizard extends React.Component { | |
constructor() { | |
this.state = { | |
currentStep: 1 | |
}; | |
this._next = this._next.bind(this); | |
this._prev = this._prev.bind(this); | |
} | |
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
class Step1 extends React.Component { | |
render() { | |
if (this.props.currentStep !== 1) { | |
return null; | |
} | |
return( | |
<p>This is step 1</p> | |
); | |
} |