Skip to content

Instantly share code, notes, and snippets.

@statianzo
Last active August 30, 2016 13:47
Show Gist options
  • Select an option

  • Save statianzo/91234d26094ad89c1ff742f41b25d737 to your computer and use it in GitHub Desktop.

Select an option

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);
@gaearon

gaearon commented Jul 31, 2016

Copy link
Copy Markdown

@burakcan This is not a solution we recommend. Those modules are internal and may be changed/removed in any release.

@burakcan

burakcan commented Aug 1, 2016

Copy link
Copy Markdown

@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