KyleAMathews / react-spinkit

A collection of loading indicators animated with CSS for React
http://kyleamathews.github.io/react-spinkit/
MIT License
1.49k stars 73 forks source link

Fix react15 warning about unknown props #36

Closed jairtrejo closed 8 years ago

jairtrejo commented 8 years ago

Links

"The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as a legal DOM attribute/property." In this case, since @props are passed as-is to the child div using ..., the div ends up with invalid html properties.

Solution

Coffeescript doesn't seem to have support for the succinct solution:

const { layout, ...rest } = props;
return <div {...rest} />

So I used Object.assign for making a copy of props and then removing the unwanted keys.

Test plan

I built the project by:

  1. Running npm install
  2. Installing webpack globally
  3. Installing React locally (perhaps consider including it in peerDependencies)
  4. Running make build

And tested it in my project using npm link. It stopped showing the warning!

jairtrejo commented 8 years ago

Hi, @KyleAMathews ! Just wanted to ping you 😄

KyleAMathews commented 8 years ago

This is great! Thanks @jairtrejo! Just reviewed and will now merge and create a new release.