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

EditButton will not re-render after custom props changes (className) #3910

Closed
Slavvkko opened this issue Oct 31, 2019 · 2 comments
Closed

EditButton will not re-render after custom props changes (className) #3910

Slavvkko opened this issue Oct 31, 2019 · 2 comments
Assignees
Labels

Comments

@Slavvkko
Copy link
Contributor

Slavvkko commented Oct 31, 2019

What you were expecting:
Change custom props in EditButton (e.g. className) trigger button re-render.

What happened instead:
EditButton wont re-render.

Steps to reproduce:
In root component:

const useStyles = makeStyles({
  editButton: {
    display: "none"
  }
});

function MyComponent() {
  const classes = useStyles();

  return (
      <EditButton
        className={classes.editButton}
        basePath={basePath}
        record={record}
      />
  )
}

After root component re-renders, useStyles will return new name for editButton and EditButton will omit this change due to shouldUpdate internal.

Related code:
From source of EditButton:

const enhance = shouldUpdate(
    (props, nextProps) =>
        props.translate !== nextProps.translate ||
        (props.record &&
            nextProps.record &&
            props.record.id !== nextProps.record.id) ||
        props.basePath !== nextProps.basePath ||
        (props.record == null && nextProps.record != null)
);

export default enhance(EditButton);

Environment

  • React-admin version: 3.0.0-beta.3
  • Last version that did not exhibit the issue (if applicable):
  • React version: 16.10.2
  • Browser: Version 78.0.3904.70 (Official Build) Arch Linux (64-bit)
  • Stack trace (in case of a JS error): not need
@Kmaschta
Copy link
Contributor

Kmaschta commented Nov 4, 2019

Thank you for opening this issue. In order to confirm it, we'll have to reproduce it.
As explained in the bug report template, please fork the following CodeSandbox and repeat your issue on it:

https://codesandbox.io/s/github/marmelab/react-admin/tree/next/examples/simple

This is the simplest way to confirm a bug is related to the React Admin codebase.

@fzaninotto
Copy link
Member

Fixed by #3929

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

No branches or pull requests

3 participants