I have a react component P that at its render function calls react comp. A and B. There is a state S of P that can be modified by A, but it is used, through a function, to retrieve some values to be used to render B. The problem is that it seems that B keeps using some old values that somehow makes it to render a table with very unbalanced columns. This is not happening at the first rendering of B. So, how can I do to "reset" or unmount "B" every time S is modified?
Note: I can not modify the code of A and B
Thanks
Code:
var UsersTable = React.createClass ({
getInitialState: function() {
return {sel_Options: this.props.ini_Options,
sel_valueArray: this.props.ini_valueArray
};
},
handleSelectChange (value) {
console.log('You\'ve selected:', value);
this.setState({sel_valueArray: value });
},
render: function() {
return(
<div>
<div>
<Select name = "form-field-name" options = {this.state.sel_Options} value = {this.state.sel_valueArray} multi={true} onChange={this.handleSelectChange}/>
</div>
<div>
<BootstrapTable data={this.props.ini_usersTbl} striped search cellEdit={ cellEditProp } height='600px' insertRow={ true } scrollTop={ 'Bottom' } multiColumnSearch={ true } options={ options } headerStyle = {{ background: '#ebf5ff'}} >
{
rAll_column_components(compsMap, this.state.sel_valueArray)
}
</BootstrapTable>
</div>
</div>
);
}
});
Here, sel_Options has the array with all the column names that can be presented on the table. sel_valueArray has the column names that the user is actually viewing on the table. rAll_column_components(compsMap, this.state.sel_valueArray) retrieves all the components that will be used to present the columns in the table.
Another note:
rAll_column_components is returning a list of TableHeaderColumn components where its elements look like:
<TableHeaderColumn dataField={'lastName'} width={'180'} dataSort headerAlign='left' editable={JSON.parse('{"type": "textarea" }')}>{'Last Name'}</TableHeaderColumn>
and everytime it is called it returns that array with the original values for each column. However, the table is able to show those columns but with the "width" property completely changed and the columns look quite unbalanced.