componentDidMount() {
console.log(return this._imgEl.getBoundingClientRect());
}
const MovieList = ...
MovieList.displayName = 'MovieList';
export MovieList;
const items = filteredProducts.filter((product) => product.category === "Some, category");
return (
<div className="products-list">
<Title title="Some Title" />
<div className="products-container">
<p>{items.length}</p>
</div>
<div className="products-container">
{items.map((product) => (
<ProductCard
key={product.id}
product = {product}
/>
)}
</div>
</div>
);
const chunks = [1,2,3,4,5,6,7].reduce((chunks, value, index) => {
const chunkIndex = Math.floor(index / 3);
if (!chunks[chunkIndex]) {
chunks[chunkIndex] = [];
}
chunks[chunkIndex].push(value);
return chunks;
}, []);
return chunks.map((chunk) => (
<div key={chunk.join(`-`)}>
{chunk.map((value) => (
<div key={value}>
{value}
</div>
))}
</div>
))
render() {
if (!this.state.users[0]) {
return null; // Или что угодно
}
return (
<InvestorBoxWrapper>
<InvestorBox>
<WithAva>
<Img src={'...'}/>
<WithAvaH3>
<H3>{this.state.users[0].id}</H3>
<H3>...</H3>
</WithAvaH3>
</WithAva>
<P>...</P>
</InvestorBox>
</InvestorBoxWrapper>
)
}
Какой метод использовать чтобы зарендерить на момент когда есть все данные данные?Нет такого.
Becausethis.props
andthis.state
may be updated asynchronously, you should not rely on their values for calculating the next state.
this.setState(
(state) => ({test: !state.test}),
() => console.log(this.state.test)
);
this.state = {...props}
this.state.props.foo
, можно будет обращаться через this.props.foo
.как теперь передать данные в эти компоненты из него?
<Route exact path='/component' render={() => <myComponent prop={value}/>} />
как сделать так, чтобы при загрузке заходило сразу на страницу '/component', а не на '/'?
<Redirect exact from='/' to='/component'/>