this.state.data[this.state.id][e.target.name] = !checked;
this.setState({
data: this.props.data,
id: this.props.id
});
const a = { key: 'value' };
const b = a;
b.key = 'new value';
console.log(a.key); // new value
this.state.data[this.state.id][e.target.name] = !checked;
render () {
const { match: { url } } = this.props;
return (
<Switch>
<Route exact path={url} content={Tweets} />
<Route exact path={url + '/with-replies'} content={WithReplies} />
<Route exact path={url + '/media'} content={Media} />
</Switch>
)
}
render() {
return someCondition ? (
<Component
prop1={a.prop1}
prop2={a.prop2}
prop3={a.prop3}
prop4={a.prop4}
prop5={a.prop5}
/>
) : (
<Component
prop1={b.prop1}
prop2={b.prop2}
prop3={b.prop3}
prop4={b.prop4}
prop5={b.prop5}
/>
);
}
render() {
const c = someCondition ? a : b;
return (
<Component
prop1={c.prop1}
prop2={c.prop2}
prop3={c.prop3}
prop4={c.prop4}
prop5={c.prop5}
/>
);
}
render() {
return (
<Wrapper>
{condition1 &&
condition2 &&
condition3 &&
condition4 && (
<Component />
)}
</Wrapper>
)
}
render() {
const shouldShowComponent = condition1 && condition2 && condition3 && condition4;
return (
<Wrapper>
{shouldShowComponent && <Component />}
</Wrapper>
);
}
или браузеры их не поддерживают и учить их тоже незачем ?
handleNoteDel = index => {
const notes = [...this.state.notes];
notes.splice(index, 1);
this.setState({ notes });
}
handleNoteDel = index => {
this.setState({
notes: this.state.notes.filter((_, i) => i !== index),
});
}
getPromoUrl = async (id, param) => {
const data = await this.getPromise(id, param);
console.log(data);
this.setState({ data });
};
getPromoUrl = (id, param) => {
this.getPromise(id, param).then(data => {
console.log(data);
this.setState({ data });
});
};
Как через рекурсию получиться произведение массива.
const result = array.reduce((acc, el) => acc * el);
Предполагается , что значение массива изначально не известно .
Вот примерный набросок, но у меня ничего не выходит.
const persistence = (number, i = 0) => {
const digits = number.toString().split('');
const result = digits.reduce((acc, el) => acc * el);
if(result > 9) {
return persistence(result, ++i);
}
return ++i;
}
Если старый добрый jQuery может выполнить все задачи проекта
Понятно что вопрос надо смотреть конкретно, но все же - какие есть явные преимущества у React/Vue и недостатки jQuery?
Или это просто от слова Мода?
const obj = {0: "ребёнак", 1: "рибёнок", 2: "ребёнок", 3: "рибёнак"};
const result = Object.values(obj).map((item, i) => (
<Button
key={i}
onPress={() => this.getQuestions(item)}
title={item}
>
{item}
</Button>
));
this.props.gamedata.questions[2].options;
this.props.gamedata.questions.map(question => (
<Question key={question.id} data={question} />
));
const result = 10 * 10 + 15 * 2;
console.log(result);
console.log(sum(square(10), double(15)));