After changing state, content is not rerendering

Asked
Active3 hr before
Viewed126 times

1 Answers

contentchangingstate
90%

Returning false does not prevent child components from re-rendering when their state changes.,– Facebook's React docs.,Component changed? Re-render. Parent changed? Re-render. Section of props that doesn't actually impact the view changed? Re-render.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Todo extends React.Component {

    componentDidMount() {
        setInterval(() => {
            this.setState(() => {
                console.log('setting state');
                return { unseen: "does not display" }
            });
        }, 1000);
    }

    render() {
        console.log('render called');
        return (<div>...</div>);
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Todo extends React.Component {

    componentDidMount() {
        setInterval(() => {
            this.setState(() => {
                console.log('setting state');
                return { unseen: "does not display" }
            });
        }, 1000);
    }

    render() {
        console.log('render called');
        return (<div>...</div>);
    }
}
load more v

Other "content-changing" queries related to "After changing state, content is not rerendering"