-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Table]: Hover and stripedRows not working if Row in another Component #4524
Comments
This happens because const ProjectRow = ({ project, ...otherProps }) => {
return (
<TableRow {...otherProps}>
<TableRowColumn>{project.name}</TableRowColumn>
<TableRowColumn>{project.date}</TableRowColumn>
</TableRow>
)
} It should be enough, let me know. |
@mmazzarolo I defined my TableRowWrapper Component as a class. I couldnt find any props that I could pass from my class to TableRow Component. |
@coco-napky Hello! render() {
const { project, ...otherProps } = this.props
return (
<TableRow {...otherProps}>
<TableRowColumn>{project.name}</TableRowColumn>
<TableRowColumn>{project.date}</TableRowColumn>
</TableRow>
)
} If you take a look at the createRows function of TableBody you'll see that it enhances it own children rows with some props ( And here comes into play your <TableBody> // It passes to its children (TableRowWrappers) some props
<TableRowWrapper project={p} key={p.get('id')}> // It passes the received props to its children (catched by ...otherProps)
<TableRow>
</TableRow>
</TableRowWrapper>
</TableBody> Hope it is clear now... and hope it helps and work for you! Let me know 🌞 |
@mmazzarolo I got it to work! Only thing to notice is that I had to take the checkbox out of the otherProps.children array and render it explicitly.
Thanks again for your time and lending out a hand. |
@coco-napky no worries, glad it worked! |
Yes thanks for pointing that out. Worked for me as well. |
Forgive me but I need to write something. I have the same problem: I have TableRowColumn wrapped into Row, because it is the only way to make onClick work (after clicking users Row it routes us to detailed user view). My code looks like this
But when I want to add |
What kind of error? class Row extends React.Component {
render() {
const { id, names, surname, birth_date, pesel } = this.props
return (
<TableRow onClick={this.props.onClickEvent} {...this.props}> // !!!
<TableRowColumn style={styles.idColumn}>{id}</TableRowColumn>
<TableRowColumn>{names}</TableRowColumn>
<TableRowColumn>{surname}</TableRowColumn>
<TableRowColumn>{birth_date}</TableRowColumn>
<TableRowColumn>{pesel}</TableRowColumn>
</TableRow>
)
}
}
function UsersTableRow(props) {
return (
<Row
id={props.id}
names={props.names}
surname={props.surname}
birth_date={props.birth_date}
pesel={props.pesel}
onClickEvent={props.onUserClick}
{...props}/> //!!!
)
} |
Right now it gives me:
And hover effect still is not working. I will try to mess around with it |
Problem description
I have a Table with several projects and their status. When My rows are rendered via a seperate component, the hover and striped effects are not applied
Steps to reproduce
My TableBody looks like this:
My Projects currently look like this:
With my ProjectRow as a separate component, the hover and stripe styles are not applied.
As soon as I directly render my Row, it would work:
Versions
The text was updated successfully, but these errors were encountered: