public function rules()
{
return [
['child_age', 'each', 'rule' => ['integer'], 'skipOnEmpty' => false],
['child_age', 'each', 'rule' => ['compare', 'compareValue' => 2, 'operator' => '>='], 'skipOnEmpty' => false]
];
}
private function log($success, $error = null)
{
if ($success) {
$this->stdout(date("Y-m-d H:i:s") . ': Success!', Console::FG_GREEN, Console::BOLD);
} else {
$this->stdout(date("Y-m-d H:i:s") . ': ' . $error, Console::FG_RED, Console::BOLD);
}
echo PHP_EOL;
}
export default function(ComposedComponent) {
class Authenticate extends React.Component {
componentWillMount() {
if (!localStorage.jwtToken) {
this.context.router.push('/auth');
}
}
componentWillUpdate(nextProps, nextState) {
if (!nextProps.isAuthenticated) {
this.context.router.push('/auth');
}
}
render() {
return (
<ComposedComponent {...this.props} />
);
}
}
Authenticate.propTypes = {
isAuthenticated: React.PropTypes.bool.isRequired,
};
Authenticate.contextTypes = {
router: React.PropTypes.object.isRequired,
};
function mapStateToProps(state) {
return {
isAuthenticated: state.auth.isAuthenticated,
};
};
return connect(mapStateToProps, { })(Authenticate);
}
<Route path="/main" component={requireAuth(MainPage)} />
class Table extends Component {
constructor(props) {
super(props);
this.handleClick = handleClick.bind(this);
}
handleClick(id) {
console.log(id);
}
render() {
return (
<div>
{items.map(item => <Item key={item.id} onClick={() => this.handleClick(item.id)} />)}
</div>);
}
}
constructor(props, context) {
super(props, context);
this.onRegionChange = this.onRegionChange .bind(this);
}