You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
Today I put together this class, so that I can make objects which I can call setState on to update in place, to add more data to a Reactable table, on demand.
Is there a more graceful way? Is this pattern going to be common enough you want me to stick this in a pull request?
varUpdateableTable=React.createClass({// on creation, specify the `initial_data` property// to modify later, update `data` with `setState`getDefaultProps: function(){vardefaultProps={initial_data: null,};returndefaultProps;},getInitialState: function(){// initialize with a dummy row (see #59)if(null===this.props.initial_data){console.log('UpdateableTable expects initial_data not to be empty');}return{data: this.props.initial_data,};},render: function(){// use data from state, rather than propertiesthis.props.data=this.state.data;returnReact.createElement(Reactable.Table,this.props);}});
The text was updated successfully, but these errors were encountered:
I've always felt that the best way to conform to the React architectural standards was to let users do the wrapping you're doing themselves - keep in mind that the use case of calling setState outside of a component is not really the way React recommends doing things - the state should exist in some sort of parent component and get set in methods on that parent component (ie, as a result of AJAX calls, user input, etc.)
Today I put together this class, so that I can make objects which I can call
setState
on to update in place, to add more data to a Reactable table, on demand.Is there a more graceful way? Is this pattern going to be common enough you want me to stick this in a pull request?
The text was updated successfully, but these errors were encountered: