Skip to content
This repository was archived by the owner on Apr 5, 2020. It is now read-only.

Possibility of Bug on passing settings #7

@amerllica

Description

@amerllica

In these lines, there is a possibility of existing of a bug:

~~~
const {
  classes,
  settings,
  children,
  anchorOriginVertical,
  anchorOriginHorizontal,
} = this.props;

return (
  <Provider value={this.getChildrenContext()}>
    {children}
    <NoSsr>
      <Snackbar
        anchorOrigin={{
          vertical: anchorOriginVertical,
          horizontal: anchorOriginHorizontal,
        }}
        open={open}
        onClose={this.handleClose}
        {...settings}
      >
~~~

The spreading of setting can overwrite the open or onClose props. we should have codes like below to avoid this possibility of the bug:

~~~
const {
  classes,
  settings: {
    open: _open,
    onClose: _onClose,
    ...restOfSettings
  },
  children,
  anchorOriginVertical,
  anchorOriginHorizontal,
} = this.props;

return (
  <Provider value={this.getChildrenContext()}>
    {children}
    <NoSsr>
      <Snackbar
        anchorOrigin={{
          vertical: anchorOriginVertical,
          horizontal: anchorOriginHorizontal,
        }}
        open={open}
        onClose={this.handleClose}
        {...restOfSettings}
      >
~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions