Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

Only one table works per page #69

Open
@billschaller

Description

@billschaller

The defaultProps object that is used in Reactable is getting polluted with the first instance of column data created. From the React docs:

getDefaultProps
    object getDefaultProps()
Invoked once and cached when the class is created. Values in the mapping will be set on 
this.props if that prop is not specified by the parent component (i.e. using an in check).

This method is invoked before any instances are created and thus cannot rely on this.props. In 
addition, be aware that any complex objects returned by getDefaultProps() will be shared across 
instances, not copied.

Because of the way columns are passed around and modified, the default props object is getting polluted with data from instances of the class. This causes the first instance of a table to work fine, but the subsequent ones all have the same columns as the first, so if they use different columns, nothing displays.

To demonstrate, navigate to http://glittershark.github.io/reactable/ and run the following code in the console:

$('body').append('<div id="testTable"></div>');
React.renderComponent(Reactable.Table({data:[{foo:'bar', baz:'qux'}]}), document.getElementById('testTable'));

I don't have time to write a good fix for this at the moment.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions