Browse Source

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 năm trước cách đây
mục cha
commit
9a8b96583a
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  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>;
   }
 
 }