let componentDidMount = JSON.parse(localStorage.getItem("comms")) || [];
let componentDidMount = localStorage.getItem("comms");
componentDidMount = JSON.parse(componentDidMount);
{el && <span>{el}</span>}
sagaGetUsers.next()
describe('users sagas', () => {
test('look on a default offset users at list', () => {
const sagaGetUsers = getQueryUserSaga()
const payload = 'default_filter=none'
expect(sagaGetUsers.next(payload).value).toEqual(take(GET_QUERY_USERS_REQUEST))
expect(sagaGetUsers.next().value).toEqual(select(filtersSelector))
})
})
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>
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() // Разница в днях
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,
]);
}
}
function isEquals(arr, arr2){
if(arr.length != arr2.length) return false
var on = 0;
for( var i = 0; i < arr.length; i++ ){
for( var j = 0; j < arr2.length; j++ ){
if(arr[i] === arr2[j]){
on++
break
}
}
}
return on==arr.length ? true : false
}
fightResolve = (a, b) =>{
const arr = [a.toLowerCase(),b.toLowerCase()]
console.log(isEquals(arr, ['a','s']))
}
fightResolve('a','S')
yield put({
type: BEGIN_FETCHING
})
yield put({
type: END_FETCHING
})
const requestInitialState = () => fetch("http://localhost:3000/data/CatalogNav.json")
.then(response => {
return response.json();
})
.then(data => {
return CatalogNav = { ...data };
console.log(CatalogNav); // {0: {…}, 1: {…}, 2: {…}, 3: {…}, 4: {…}} - выводит заполненный объект
});