Skip to content

Instantly share code, notes, and snippets.

@variousauthors
Created June 13, 2018 21:53
Show Gist options
  • Save variousauthors/cd228924f4404afc08b5c724692f4920 to your computer and use it in GitHub Desktop.
Save variousauthors/cd228924f4404afc08b5c724692f4920 to your computer and use it in GitHub Desktop.
You need to add a className or the styles won't render
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