Skip to content

Instantly share code, notes, and snippets.

@davidrosenlund
Created November 25, 2019 18:28
Show Gist options
  • Save davidrosenlund/21489ba2511170090ba3bc5e176ed044 to your computer and use it in GitHub Desktop.
Save davidrosenlund/21489ba2511170090ba3bc5e176ed044 to your computer and use it in GitHub Desktop.
Parent App.js
########################
const BonusContext = React.createContext(false);
class App extends Component {
static contextType = BonusContext;
render() {
return(
<li className={ this.contaxt ? 'current' : '' }>
<NavLink
exact
to="/bonuses"
data-hover="Alla Bonusar">
Alla Bonusar
</NavLink>
</li>
);
}
}
Child component Bonuses.js
#########################
const BonusContext = React.createContext(true);
class Bonuses extends Component {
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment