state = {array : []}
)const newArray = this.state.array
newArray.push('test')
this.setState({array : newArray})
componentDidMount() {
if (!selectRoot) {
const newNode = document.createElement('div')
newNode.setAttribute('id', 'select-root')
const rootNode = document.querySelector('#root')
rootNode.after(newNode)
newNode.appendChild(this.el)
} else {
selectRoot.appendChild(this.el)
}
}
const colors = [#000, #333, #555 , #etc...]
class BackgroundSwitcher extends React.Component {
render() {
return (
<>
{colors.map(color => <Hero background={color} />)}
</>
);
}
}
const Hero = (props) => <div className="hero" style={{background: props.background}}>
<img src="images/heroes/flash.jpg"/>
<div className="hero-desc">
<h1>Flash</a>
<h3>Three men have held the title of "The Fastest Man Alive" -- Jay Garrick, Barry Allen, and Wally West -- each of them redefined the word "hero."</a>
</div>
</div>
import {Login, LoginWrap, DataInput} from '../styledComponents/login.js'
return(
<LoginWrap>
<Login>
<img src={logo} alt='logo'/>
<h3>Login</h3>
<DataInput>
<input placeholder='Login' ref={loginInput}/>
<input placeholder='Password' type='password' ref={passInput}/>
</DataInput>
<span>{loginError}  </span>
<input type='submit' value='Login' onClick={onLogin}/>
</Login>
</LoginWrap>
)
let a = moment("2018-03-10", "YYYY-MM-DD"); // 1я дата (1й аргумент строковая дата, 2й аргумент формат даты)
let b = moment("2018-03-10", "YYYY-MM-DD"); // 2я дата
a.diff(b, 'days') // Разница в днях
// Либо так
moment.duration(a.diff(b)).asDays() // Разница в днях
<Switch>
<Redirect
from={"/first"}
exact
to={"/first/item1"}
render={() => <Item {...props}/>}
/>
<Route
path={"/first/item1"}
render={() => <Item {...props}/>}
/>
<Route
path={ '/first/item2'}
render={() => <List {...props}/>}
/>
</Switch>
selector{
display: flex;
align-items: left;
max-width: 40px;
overflow-x: hidden;
white-space: nowrap;
}
text-overflow: ellipsis;
class User extends ActiveRecord
{
const SCENARIO_STEP1 = 'step1';
const SCENARIO_STEP2 = 'step2';
...
public function scenarios()
{
return [
self::SCENARIO_STEP1 => ['attr1', 'attr2'],
self::SCENARIO_STEP2 => ['attr3', 'attr4', 'attr5'],
];
}
...
public function actionStep1()
{
$model = new OrderWizard();
$model->setScenario(OrderWizard::SCENARIO_STEP1);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['step-2', 'id' => $model->id]);
} else {
return $this->render('step-1', [
'model' => $model,
]);
}
}