Answer the question
In order to leave comments, you need to log in
How to execute render with a delay?
I have this code
export class Node extends Component {
renderChild = childId => {
const { id } = this.props;
return (
<li key={childId}>
<ConnectedNode id={childId} parentId={id} />
</li>
)
};
render() {
const { parentId, childIds, type, _value, _key } = this.props;
return (
<div>
{type == 'object' && _value && <span>{</span>}
{type == 'object' && !_value && <span><b>{_key} :</b> {</span>}
{type == 'array' && <span><b>{_key} :</b> [</span>}
{type == 'object array' && <span>{</span>}
{type == 'string' && <span><b>{_key} :</b>{_value}</span>}
{childIds.length && <ul style={{listStyle: 'none', paddingLeft: '24px'}}>
{childIds.map(this.renderChild)}
</ul>}
{type == 'object' && <span> }</span>}
{type == 'object array' && <span> }</span>}
{type == 'array' && <span>]</span>}
</div>
)
}
}
function mapStateToProps(state, ownProps) {
return state.entity.structure[ownProps.id]
}
const ConnectedNode = connect(mapStateToProps, actions)(Node);
export default ConnectedNode;
Answer the question
In order to leave comments, you need to log in
setTimeout(()=>{
//Код - контекст привязал через стрелочную функцию
}, 5000)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question