class Person {
constructor(name, surname, age) {
this.name = name;
this.surname = surname;
this.age = age;
}
changeAge(num) {
this.age = this.age + num;
return this;
}
}
const person = new Person('John', 'Smith', 31);
test.map(i => {
delete i.id;
delete i.name;
delete i.ratio;
delete i.show;
});
saveCustomChart(e) {
e.preventDefault();
let { test } = this.props;
const { name } = this.state;
test = test.filter(el => el.show)
.map(({ someValue1, someValue2 }) => ({ someValue1, someValue2 }));
ajax({
// no changes
});
}
class myClass {
constructor(prop1, prop2) {
this.prop1 = prop1;
this.prop2 = prop2;
}
static createSomeObj() {
return new myClass('prop1 value', 'prop2 value');
}
}
<link rel="stylesheet" href="/libs/bootstrap/bootstrap-grid-3.3.2.min.css" />
<link rel="stylesheet" href="/css/fonts.css" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="stylesheet" href="/css/media.css" />
<link rel="stylesheet" href="/css/animate.min.css"/>
isSomeCondition && <Component />
alert(5 && 10);
alert(0 && 10);
alert(1 && 2 && 3 && 4 && 5 && 6 && 7 && 8 && 9 && 10);
alert(1 && 2 && 3 && false && 5 && 6 && 7 && 8 && 9 && 10);
return (
...
{arr.length && <SomeComponent />}
);
const shouldShowSomeComponent = !!arr.length;
return (
...
{shouldShowSomeComponent && <SomeComponent />}
);
const shouldShowSomeComponent = arr.length > 0;
return (
...
{shouldShowSomeComponent && <SomeComponent />}
);
Вы передаете в свойство key индекс, а индекс у вас всегда 0. Так делать нельзя. Документация.
Само решение рендерить фильтры через map ужасно.
По хорошему это все надо переписать.