Skip to content
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

tableRow can not choose, if using setState in onRowSelection #3734

Closed
stephenkingsley opened this issue Mar 18, 2016 · 10 comments
Closed

tableRow can not choose, if using setState in onRowSelection #3734

stephenkingsley opened this issue Mar 18, 2016 · 10 comments
Labels
component: table This is the name of the generic UI component, not the React module!

Comments

@stephenkingsley
Copy link

Problem Description

Versions

  • Material-UI:
  • React:
  • Browser:
@stephenkingsley stephenkingsley changed the title tableRow can not choose, if using setState in inRowSelection tableRow can not choose, if using setState in onRowSelection Mar 18, 2016
@juliengroch
Copy link

Hi,

I have exactly the same issue 👎

@mbrookes mbrookes closed this as completed Apr 2, 2016
@nathanmarks
Copy link
Member

The issue description here is a real winner.

@juliengroch
Copy link

I see my problem, i have a bad code beetween setState (call new rendering cycle) and render

@caio-ribeiro-pereira
Copy link

I'm in the same issue :(

@stephenkingsley
Copy link
Author

i think mui V15 has this issue, mui V14.0.4 is right.

@zo-chu
Copy link

zo-chu commented May 13, 2016

Is there a solution to this problem? if i call setState in onRowSelected it stops from showing me selected rows with highlight but row numbers appear in console correctly. (this state setting shouldnt couse rerendering , i jast pass it to another component) Thanks.

@killroy42
Copy link

I have the same problem. Why is this closed? In my case the selection updates state which should update another component. The selection never is visualized in the table.

@hitlxc
Copy link

hitlxc commented Feb 5, 2017

It seems that the bug has been fixed in the latest version .I solved this problem by 'npm install material-ui'

@hayesmaker
Copy link

this is still broken in 0.18.1

@niron1
Copy link

niron1 commented Dec 25, 2017

there is an issue with material-ui's table "forgetting" its checked status each render.
to overcome this problem you can specifically set the checked state in the map function like so:

            <TableRow key={index}
              selected={this.state.selectedRows.indexOf(index) !== -1}>
            </TableRow>

now that you maintain the checked status yourself you should have something like

  onRowSelection(selectedRows) {
    this.setState({ selectedRows });
  }

and

      <Table
        onRowSelection={this.onRowSelection}

and

  constructor(props) {
    super(props);
    this.onRowSelection = this.onRowSelection.bind(this);
  }

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added component: table This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: table This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests