Skip to content

Server-side rendering and Insert Row #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
redjab opened this issue Mar 22, 2016 · 5 comments
Closed

Server-side rendering and Insert Row #348

redjab opened this issue Mar 22, 2016 · 5 comments

Comments

@redjab
Copy link

redjab commented Mar 22, 2016

Hi, I'm using react-bootstrap-table and running into this issue when set insertRow={true}

vendor.bundle.js:52234 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) le-modal-sm1458619137421" data-reactid="
 (server) le-modal-sm1458619135871" data-reactid="

I think it has something to do with the pop up modal on inserting new row.

Using:
react-bootstrap-table: 2.0.2
react: 0.14.2
jquery: 2.1.4
bootstrap: 3.3.5

Would appreciate any help on the issue!

@AllenFang
Copy link
Owner

Hi @redjab, could you please confirm there's no error if you only disable insertRow? Thanks!

@redjab
Copy link
Author

redjab commented Mar 22, 2016

Hi @AllenFang, yes I can confirm that there's no error if I only disable insertRow
Here is the BootstrapTable code:

var tableOptions = {
    afterInsertRow: this.onAfterInsertRow.bind(this),
    afterDeleteRow: this.onAfterDeleteRow.bind(this)
}
var cellEditProp = {
    mode: "click",
    blurToSave: true,
    afterSaveCell: this.onAfterSaveCell.bind(this)
}

var persistentOption = {
    type: 'checkbox',
    options: {
        values: 'Yes:No'
    }
}
var selectRowProp = {
  mode: "checkbox", // or checkbox
  clickToSelect: true
};

<BootstrapTable
    striped={true}
    data={this.state.attributes}
    cellEdit={cellEditProp}
    insertRow={true}
    deleteRow={true}
    selectRow={selectRowProp}
    options={tableOptions}>
    <TableHeaderColumn dataField="id" isKey={true} hidden={true} autoValue={true}>Attribute ID</TableHeaderColumn>
    <TableHeaderColumn dataField="name">Name</TableHeaderColumn>
    <TableHeaderColumn dataField="default">Default</TableHeaderColumn>
    <TableHeaderColumn dataField="persistent" editable={persistentOption}>Persistent</TableHeaderColumn>
</BootstrapTable>

@AllenFang
Copy link
Owner

@redjab, I know the problem, le-modal-sm1458619137421 is a classname, but 1458619137421 is a timestamp which will be generated when render insert modal. But actually classname should be bs-table-modal-sm1458619137421. However, I need to find another solution to avoid use a timestamp to avoid a unique classname.

@redjab
Copy link
Author

redjab commented Mar 22, 2016

Make senses. On top of my head, may be it will be easiest for the user to pass in a prop as the id instead of generating one?
So instead of insertRow={true} you can do something like
insertRow = { data-target-id: 1 }

@AllenFang
Copy link
Owner

@redjab, I've fixed this issue on v2.1.0. Check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants