Material-ui: On the Chip onDelete event it doet not have target name

Created on 7 Nov 2018  ·  3Comments  ·  Source: mui-org/material-ui

Expected Behavior

When calling onDelete on a chip. The Event should bring back its proper name.

Current Behavior

Returns Undefined.

Steps to Reproduce

See https://codesandbox.io/s/j4qv2q0k85

| Tech | Version |
|--------------|---------|
| @material-ui/core | 3.4.0|

Chip question

Most helpful comment

try something like: onDelete={checkListToggle.bind(this, 'keyName')}
Worked in my case

All 3 comments

The workaround is to do:

import ReactDOM from "react-dom";
import React from "react";
import { Chip } from "@material-ui/core";

class App extends React.Component {
  checkListToggle = name => event => {
    alert(name);
  };
  render() {
    return (
      <div>
        <Chip
          name="keyName"
          label="keyname"
          color="primary"
          onDelete={this.checkListToggle('keyName')}
        />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("root"));

Thank you for a response. I can do a workaround without a problem. However, that workaround it not allowed by es lint because of no-multi-assign. I just thought it might be a good idea to change the behavior. Not sure if its that big pressing issue for you guys.

try something like: onDelete={checkListToggle.bind(this, 'keyName')}
Worked in my case

Was this page helpful?
0 / 5 - 0 ratings