material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[chip] gets warning when I put inside <p> element

Open blmarket opened this issue 10 years ago • 4 comments

Problem description

React warning validateDOMNesting occurs when I put Chip element inside p element. hope Chip uses other than 'div' as containerElement. how about using 'span' instead?

Steps to reproduce

render() {
  <p><Chip ... /></p>
}

javascript console says,

warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>. See DetailItem > p > ... > Chip > EnhancedButton > div.

Versions

  • Material-UI: 0.15.2
  • React: 15.2.1
  • Browser: electron 1.2.5

blmarket avatar Jul 26 '16 02:07 blmarket

I didn't tested much with 'span', but at least it works on my environment(and hopefully in chrome). I'll create PR for this if it seems okay to be changed.

blmarket avatar Jul 26 '16 02:07 blmarket

The validateDOMNesting warning was expected when using <p> tags around the Chip component. Use <div> tag instead. @oliviertassinari Does the idea of making a PR to use to use span instead of div to make the Chip component seem okay to you? If yes, then I will make a PR, otherwise this is ready to be closed.

Shahrukh-Zindani avatar Feb 20 '17 19:02 Shahrukh-Zindani

You should be able to use the containerElement property. However, the component doesn't allow it. You need to change the override order. Users should have the highest priority.

oliviertassinari avatar Feb 25 '17 10:02 oliviertassinari

Sounds great to make a contribution! I'll make a PR to make containerElement configurable.

blmarket avatar Feb 25 '17 13:02 blmarket