this.setState(state => Object
.keys(state)
.reduce((acc, n) => (acc[n] = n === 'свойствоКотороеДолжноБытьTrue', acc), {})
);
git remote -v
origin https://github.com/YaroslavShilov/Blank.git/ (fetch)
origin https://github.com/YaroslavShilov/Blank.git/ (push)
git remote rm origin
git remote add origin git@github.com:YaroslavShilov/Blank.git
git remote -v
origin git@github.com:YaroslavShilov/Blank.git (fetch)
origin git@github.com:YaroslavShilov/Blank.git (push)
const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
[...str].map(letter => pairs[letter.toLowerCase()] || letter).join``;
const pairs = { a: 'ა', b: 'ბ', g: 'გ'};
const str = 'There are many ways that reading helps you to learn English.';
str.replace(RegExp(Object.keys(pairs).join('|'), 'gi'), letter => pairs[letter.toLowerCase()]);
сначала сделать запрос <...> после чего отрисовать страницу
state = {
active: null,
}
toggle = ({ target: { dataset: { name } } }) => {
this.setState(({ active }) => ({
active: active === name ? null : name,
}));
}
<button onClick={this.toggle} data-name="collapse_1"></button>
<button onClick={this.toggle} data-name="collapse_2"></button>
<button onClick={this.toggle} data-name="collapse_3"></button>
toggle = ({ target: { dataset: { name } } }) => {
this.setState(({ collapse }) => ({
collaple: {
...collapse,
[name]: !collapse[name],
},
}));
}
class ExampleComponent extends React.Component {
state = {
isReady: false,
};
hanldeOnLoad = () => {
this.setState({ isReady: true });
};
render() {
const { src } = this.props;
const { isReady } = this.state;
const className = isReady ? '' : 'some-class';
return (
<div className={className}>
<img onLoad={this.hanldeOnLoad} src={src} />
</div>
);
}
}
const Grid extends React.Component {
state = { itemsSize: 'sm' };
handleChangeSize = () => { /* some code */ };
render() {
const { itemSize } = this.state;
const { items } = this.props;
return (
<Wrapper>
<ControlPanel onChangeSize={this.handleChangeSize} />
{items.map(item => <Item key={item.id} size={this.state.itemSize} />)}
</Wrapper>
);
}
}