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

Setstate needs to test if it's mounted before running #26

Open
chrisjpatty opened this issue Mar 29, 2018 · 4 comments
Open

Setstate needs to test if it's mounted before running #26

chrisjpatty opened this issue Mar 29, 2018 · 4 comments
Assignees
Labels

Comments

@chrisjpatty
Copy link
Owner

Currently the components don't test if they're mounted before firing a setState. This leads to an occasional case where components throw React's setState error. Each component should internally track their mounted state as described here

@chrisjpatty chrisjpatty self-assigned this Mar 29, 2018
@TrySound
Copy link
Collaborator

I think this problem is automatically eliminated with synchronous unsubscribe from store via willUnmount hook, what we currently do now.

@chrisjpatty
Copy link
Owner Author

Something in the timing must be a little bit off then. I'm getting the setState error when I use it like so: https://www.useloom.com/share/71f0474ebfd44a779cf0f3d4c9f44cf1

@chrisjpatty
Copy link
Owner Author

It's in the case where I have a Droppapble nested inside of another Droppable. The inner Droppable throws the error because it's only rendered while dragging, and unmounts immediately after.

@chrisjpatty
Copy link
Owner Author

<Droppable>
  {
    ({isOver, events, isDragging, type}) => (
      <div className={(isOver ? "section is-over " : "section ") + (selected ? "active" : " ")} {...events}>
        {
          selected && !isFirst ?
          <button className="reorder up" onClick={this.moveUp} ><span className="icon icon-caret-up"></span></button>
          : null
        }
        <h4 onClick={this.selectSection}>
          {title !== "" ? title : " "}
        </h4>
        {
          description ?
          <ReactMarkdown className="description" source={description} />
          :
          null
        }
        {children}
        {
          isDragging && type === 'field' ?
          <div className="drag-mask">
            <Droppable accepts='field' onDrop={this.fieldDropped}>
              {
                ({events}) => (
                  <div className="field-drop" {...events}>
                    Drop field here to add
                  </div>
                )
              }
            </Droppable>
          </div>
          :
          null
        }
        <div className="bottom-divider"></div>
        {
          selected && !isLast ?
          <button className="reorder down" onClick={this.moveDown}><span className="icon icon-caret-down"></span></button>
          : null
        }
      </div>
    )
  }
</Droppable>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants