Skip to content

Commit

Permalink
:removed unnecessary component state
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisshriov committed Jan 22, 2020
2 parents bd6427a + 1014770 commit 3b3c69e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions docs/blog/2017-10-17-building-i18n-with-gatsby/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,6 @@ class LanguageSwitcher extends Component {
this.handleChangeLanguage = this.handleChangeLanguage.bind(this)
}

static getDerivedStateFromProps(nextProps, prevState) {
if(nextProps.i18n.language !== prevState.i18n.language){
return { language: nextProps.i18n.language }
}
return null
}

handleChangeLanguage(lng) {
const { i18n } = this.props
i18n.changeLanguage(lng)
Expand Down Expand Up @@ -280,8 +273,8 @@ class LanguageSwitcher extends Component {
export default translate("LanguageSwitcher")(LanguageSwitcher)
```

This is a pretty simple component. We're setting the `language` state based on
the i18n prop so that we can check which language is currently active and show
This is a pretty small component. We're getting the `language` in the
i18n prop so that we can check which language is currently active and show
that in our menu.

The `handleLanguageChange` function just wraps the `react-i18n` function passed
Expand Down

0 comments on commit 3b3c69e

Please sign in to comment.