Last active
August 30, 2016 13:47
-
-
Save statianzo/91234d26094ad89c1ff742f41b25d737 to your computer and use it in GitHub Desktop.
unknown props warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gaearon, yes we're aware of that. But in that case, there's only one file to change.