Skip to content

Instantly share code, notes, and snippets.

@statianzo
Last active August 30, 2016 13:47
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statianzo/91234d26094ad89c1ff742f41b25d737 to your computer and use it in GitHub Desktop.
Save statianzo/91234d26094ad89c1ff742f41b25d737 to your computer and use it in GitHub Desktop.
unknown props warning
const ContactBadge = (props) => (
<div className='Badge' {...props}>
<div>{props.user.name}</div>
<div>{props.contactMethod.type}</div>
</div>
);
export default connect((state, {userId, contactMethodId}) => ({
user: selectUser(state, userId),
contactMethod: selectContactMethod(state, contactMethodId)
}))(ContactBadge);
//Using clone+delete to satisfy unknown props warning
const ContactBadge = (props) => {
const divProps = {...props};
delete divProps.user;
delete divProps.contactMethod;
delete divProps.userId;
delete divProps.contactMethodId;
delete divProps.dispatch;
return (
<div className='Badge' {...divProps}>
<div>{props.user.name}</div>
<div>{props.contactMethod.type}</div>
</div>
);
};
export default connect((state, {userId, contactMethodId}) => ({
user: selectUser(state, userId),
contactMethod: selectContactMethod(state, contactMethodId)
}))(ContactBadge);
//Using destructuring to satisfy unknown props warning
const ContactBadge = ({user, contactMethod, userId, contactMethodId, dispatch, ...rest}) => (
<div className='Badge' {...rest}>
<div>{user.name}</div>
<div>{contactMethod.type}</div>
</div>
);
export default connect((state, {userId, contactMethodId}) => ({
user: selectUser(state, userId),
contactMethod: selectContactMethod(state, contactMethodId)
}))(ContactBadge);
@burakcan
Copy link

burakcan commented Aug 1, 2016

@gaearon, yes we're aware of that. But in that case, there's only one file to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment