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

[TextField] onTouchTap on label

Open johntran opened this issue 9 years ago • 6 comments

Problem description

When calling "mount" on Enzyme on "TextField", this error occurs in Jest:

console.error node_modules/fbjs/lib/warning.js:36
      Warning: Unknown prop `onTouchTap` on <label> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
          in label (created by TextFieldLabel)
          in TextFieldLabel (created by TextField)
          in div (created by TextField)
          in TextField (created by AddressField)
          in AddressField (created by PhoneNumberInput)
          in PhoneNumberInput (created by Unknown)
          in Unknown

Link to minimally-working code that reproduces the issue

import 'jsdom-global/register';
import React, {PropTypes} from 'react';
import { mount } from 'enzyme';
import TextField from 'material-ui/TextField';
import getMuiTheme from 'material-ui/styles/getMuiTheme';

describe('TextField Component', () => {
  const muiTheme = getMuiTheme();
  const context = { muiTheme };
  const childContextTypes = { muiTheme: React.PropTypes.object };
  it('console error', () => {
    const wrapper = mount(
      <TextField floatingLabelText='hi'/>, { context, childContextTypes }
    );
    expect(1).toBe(1);
  });
});

Versions

  • Material-UI: 0.16.5
  • React: 15.4.1
  • Browser: N/A

johntran avatar Dec 23 '16 13:12 johntran

This happens with the example code provided on the website (http://www.material-ui.com/#/get-started/usage) as well.

CryZe avatar Jan 10 '17 21:01 CryZe

They suggested using a plugin to avoid this warning but I think it's kind of annoying because at least I don't want an extra plugin for this single warning.

lijunray avatar Jan 12 '17 16:01 lijunray

@CryZe Please submit a PR preferably (or separate issue otherwise) for that.

mbrookes avatar Jan 13 '17 18:01 mbrookes

@johntran https://github.com/callemall/material-ui/issues/5390#issuecomment-260974005

mbrookes avatar Jan 17 '17 20:01 mbrookes

This happens to me as well, specifically on "TextFieldLabel" component like above. I am already calling injectTapEventPlugin at the top of my entry point, but it doesn't help. I still get the warning.

amirmohsen avatar Feb 28 '17 16:02 amirmohsen

@mbrookes Calling injectTapEventPlugin fixed it for me :)

johntran avatar Mar 01 '17 05:03 johntran