/.jsx
Last active
November 25, 2019 18:37
-
-
Save jkantr/c2809697cb098305edf6ad03bf91788b to your computer and use it in GitHub Desktop.
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
import BonusContext from './bonus-context'; | |
class App extends Component { | |
static contextType = BonusContext; | |
render() { | |
return( | |
<li className={ this.context ? '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 { | |
... | |
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
export const BonusContext = React.createContext({ | |
bonus: false | |
toggleBonus: () => this.bonus = !this.bonus | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment