felixrieseberg / felixrieseberg/React-Dropzone-Component

Dynamically pass djsConfig params based on parent's props.

Open
#26 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
999
Forks
148
PR merge metrics
No merged PRs in 30d

Description

Hey, thanks for the component. I'm trying to dynamically set the djsConfig params based on the parent's props, like so:

``` js
var Table = React.createClass({
render() {
var that = this;
var dropzoneConfig = {...};
var eventHandlers = {...};

var djsConfig = {
uploadMultiple: true,
maxFilesize: 11,
params: {
id: that.props.id,
name: that.props.name
}
};

return(

);

}
});​
```

From what I understand the problem is that because dropzone gets initialized only on `componentDidMount` the props won't be passed down on the parent component's first re-render for some reason.

To explain further, say I have `Table A` and `Table B` in a list view, both clickable and they go to their single table view (with react router). I click on Table A for the first time, everything works as expected. Go back to the list, click on Table B, the `djsConfig` object still has Table A’s `id` and `name` props. If I go back and load Table B again _only then_ are the correct props set.

Is there any workaround for this?

For the time I hacked around the source and added

``` js
componentWillReceiveProps: function() {
this.dropzone.destroy();
this.componentDidMount();
},
```

which is really bad. I'd appreciate any input.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by inspecting the componentDidMount implementation and the lifecycle path used when parent props change. Reproduce navigation from Table A to Table B and trace which djsConfig values reach Dropzone. Done means each table view uses its current id and name without requiring a second visit or destroying and remounting the component.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.