Created
June 13, 2018 21:53
-
-
Save variousauthors/cd228924f4404afc08b5c724692f4920 to your computer and use it in GitHub Desktop.
You need to add a className or the styles won't render
This file contains hidden or 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
interface IBobProps { | |
name: string | |
} | |
class Bob extends React.PureComponent<IBobProps> { | |
render () { | |
<div>HELLO, {this.props.name}</div> | |
} | |
} | |
// get the user name from the store | |
const BobConnected = connect( | |
(state, props) => { return state.users[props.userId].name } | |
)(Bob) | |
// gussy up that name | |
const BobFancyConnected = styled(BobConnected)` | |
color: red; | |
` | |
// the name will NOT be red!!! | |
// we need to add a className to the component | |
interface IBobProps { | |
name: string | |
className?: string | |
} | |
class Bob extends React.PureComponent<IBobProps> { | |
render () { | |
<div className={this.props.className}>HELLO, {this.props.name}</div> | |
} | |
} | |
// Now when we connect and style Bob it will render the red |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment