Преглед изворни кода

Fix Link props order with spread operator

When using props in conjunction with the spread operator, values provided last override earlier ones. 

If you're using `Link` as an actual component and specified a custom `onClick` handler, `Link.handleClick` would never get executed because it's overridden by `{...props}` being last.
Andrew Cobby пре 9 година
родитељ
комит
9a8b96583a
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      components/Link/Link.js

+ 1 - 1
components/Link/Link.js

@@ -53,7 +53,7 @@ class Link extends Component {
 
   render() {
     const { to, children, ...props } = this.props;
-    return <a onClick={Link.handleClick.bind(this)} {...props}>{children}</a>;
+    return <a {...props} onClick={Link.handleClick.bind(this)}>{children}</a>;
   }
 
 }