sarink / react-file-drop

React component for Gmail or Facebook -like drag and drop file uploader

Home Page:https://www.sarink.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested FileDrop triggering onDrop event multiple time. One for child component and one for parent component. please guide how to resolve this issue.

MuhammadAli-208 opened this issue · comments

        <FileDrop
          onDrop={(files, event) => console.log('DropEd on Main Folder!', files, event)}
        >
          {files.map((f, i) => (
            <Row key={i}  >
              <Col span={12}  >
                {f.isDir ?
                  <span style={stylesDir}>
                    <FileDrop onDrop={(files, event) => console.log(`DropEd on child Folder ${f.name}`, files, event)}>
                      {f.name}
                    </FileDrop>
                  </span>
                  : f.name}
              </Col>
              <Col span={12}  >
                {f.size}
              </Col>
            </Row>
          ))}
        </FileDrop>

This is just how events work, they will always bubble upwards in the tree. You can call something like event.stopPropagation() and/or event.preventDefault() to prevent this.