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

inputs: React doesn't like camelCase props on dom elements #709

Closed
stuller opened this issue Mar 22, 2018 · 5 comments
Closed

inputs: React doesn't like camelCase props on dom elements #709

stuller opened this issue Mar 22, 2018 · 5 comments

Comments

@stuller
Copy link
Contributor

stuller commented Mar 22, 2018

We recently updated input components to pass down all props so we could use things like autoFocus, but now we are getting JS warnings in console because "React does not recognize the isValid prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase isvalid instead. If you accidentally passed it from a parent component, remove it from the DOM element."

Basically this happens for any camelcase prop, including the ones used by Atlas like isValid, errorText, and iconTooltip.

We do still want it to pass down anything that a dom element could use, like autoFocus or data attributes.

Derek thinks he's got a solution.

@Darper
Copy link
Contributor

Darper commented Mar 23, 2018

Lol. Such little faith with that last paragraph.

@stuller
Copy link
Contributor Author

stuller commented Mar 23, 2018

lol was trying to avoid over-committing you. i have full confidence 😄

Darper pushed a commit to Darper/react-atlas that referenced this issue Mar 23, 2018
@Raymans
Copy link
Contributor

Raymans commented Mar 28, 2018

#716 uses custom prop types to filter out from spread, this case we don't hacky eslint and let render method more clear and focused, but still, duplicate with propTypes (needed for styleguide).

hopefully we could use spread in propTypes like

Input.customPropTypes = {
  "errorText": PropTypes.string,
  "isValid": PropTypes.bool,
  "validator": PropTypes.func,
  "onBeforeChange": PropTypes.func,
  "uppercase": PropTypes.bool,
  "mask": PropTypes.string
};

Input.propTypes = {
  ...Input.customPropTypes,
  "isValid": PropTypes.bool,

but which is not supported in styleguide yet.
styleguidist/react-styleguidist#792
reactjs/react-docgen#246

any idea could be better?

@Raymans
Copy link
Contributor

Raymans commented Mar 28, 2018

Checkbox, Dropdown, Radio, Switch also need to be handled

@Darper
Copy link
Contributor

Darper commented Apr 3, 2018

Closed by PR #716

@Darper Darper closed this as completed Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants