Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite loop with setState( { dirty...} #39

Open
tcoldmf opened this issue Sep 5, 2019 · 1 comment
Open

infinite loop with setState( { dirty...} #39

tcoldmf opened this issue Sep 5, 2019 · 1 comment
Assignees

Comments

@tcoldmf
Copy link

tcoldmf commented Sep 5, 2019

Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

{snip} .getElementHeight(this.wrapper);t===this.state.height?this.setState({dirty:!1}):this.setState({height:t,dirty:!1},function(){return e.props. {snip}

Code:

        <ReactHeight onHeightReady={ height => setHiddenContent( height > props.maxHeight )}>
          {
            hidden_content &&
              <div
                style={{
                    top: '120px',
                    height: '80px',
                    width: '100%',
                    position: 'absolute',
                    backgroundImage: 'url(/assets/images/mensajero/degradado.png)',
                }}
              />
          }
          { props.children.contentToCollapse }
        </ReactHeight>
@nkbt
Copy link
Owner

nkbt commented Nov 8, 2019

Please provide a working codepen (or any online example) I can check. At this point I can only assume that when you setHiddenContent your component changes children which triggers ReactHeight update, which calls onHeightReady and so on in a loop, thus you need to limit updates in your App instead (using setState or anything else that will not create new children for any new height that is probably even same)

@nkbt nkbt self-assigned this Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants