-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use arrow functions where possible (#1762)
- Loading branch information
1 parent
5c3c3eb
commit 46e8ea5
Showing
9 changed files
with
67 additions
and
82 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,27 +18,23 @@ export class ReportNamespaces { | |
}); | ||
} | ||
|
||
getUsedNamespaces() { | ||
return Object.keys(this.usedNamespaces); | ||
} | ||
getUsedNamespaces = () => Object.keys(this.usedNamespaces); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
VIKTORVAV99
Author
Contributor
|
||
} | ||
|
||
export function composeInitialProps(ForComponent) { | ||
return async (ctx) => { | ||
const componentsInitialProps = ForComponent.getInitialProps | ||
? await ForComponent.getInitialProps(ctx) | ||
: {}; | ||
export const composeInitialProps = (ForComponent) => async (ctx) => { | ||
const componentsInitialProps = ForComponent.getInitialProps | ||
? await ForComponent.getInitialProps(ctx) | ||
: {}; | ||
|
||
const i18nInitialProps = getInitialProps(); | ||
const i18nInitialProps = getInitialProps(); | ||
|
||
return { | ||
...componentsInitialProps, | ||
...i18nInitialProps, | ||
}; | ||
return { | ||
...componentsInitialProps, | ||
...i18nInitialProps, | ||
}; | ||
} | ||
}; | ||
|
||
export function getInitialProps() { | ||
export const getInitialProps = () => { | ||
const i18n = getI18n(); | ||
const namespaces = i18n.reportNamespaces ? i18n.reportNamespaces.getUsedNamespaces() : []; | ||
|
||
|
@@ -55,4 +51,4 @@ export function getInitialProps() { | |
ret.initialLanguage = i18n.language; | ||
|
||
return ret; | ||
} | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
let i18nInstance; | ||
|
||
export function setI18n(instance) { | ||
export const setI18n = (instance) => { | ||
i18nInstance = instance; | ||
} | ||
}; | ||
|
||
export function getI18n() { | ||
return i18nInstance; | ||
} | ||
export const getI18n = () => i18nInstance; |
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
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
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
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
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
Hi this commit is "use arrow functions where possible" but arrow function with class property is not common arrow function it depends on special babel plugin:
screenshot from https://www.freecodecamp.org/news/react-binding-patterns-5-approaches-for-handling-this-92c651b5af56/.
And it broke one of my project: