question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different functions with the same name

See original GitHub issue

Description:

I got rerendering issue while use const { t } = useTranslation() of react-i18next. In my research, the inside of useTranslation hook used useState to store a getT function. Wrapping getT function inside useCallback hook could not prevent getting this message from WDYR

different functions with the same name

function getT() {
    return i18n.getFixedT(null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0]);
}

https://github.com/i18next/react-i18next/blob/master/src/useTranslation.js#L42-L45

setT(getT);

https://github.com/i18next/react-i18next/blob/master/src/useTranslation.js#L82

Could you please confirm that issue comes from react-i18next? Thanks 🙇🏻

Reproduction:

Repo: https://github.com/zcmgyu/react-i18next-rerender-issue

Screen Shot 2021-04-06 at 12 33 17 Screen Shot 2021-04-06 at 12 33 33

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
vzaidmancommented, Apr 6, 2021
0reactions
zcmgyucommented, Apr 6, 2021

@vzaidman I’ve already checked it with the non-Gatsby project. The useTranslation hook will not cause any re-render issue while initial. If I intentionally cause the BigListPureComponent to be re-rendered then I will get the same rerender warning message as above.

https://codesandbox.io/s/why-did-you-render-sandbox-forked-891xf?file=/src/index.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

More info about 'different functions with the same name' #33
There are not different functions with the same name...there is only one function with a particular name so not sure why this warning...
Read more >
In programming, what do you call functions with the same ...
If the functions have the same name but different signatures within the same class, it is overloading. If they have the same name...
Read more >
Can I have more than one function with the same name?
One function can be given many names, but many functions cannot have the same name. If we happen to declare two functions of...
Read more >
Can variables belonging to different functions have same name
Yes, variables belonging to different function can have same name because their scope is limited to the block in which they are defined....
Read more >
How can different functions have the same name? [duplicate]
It's called "function overloading" (or "method overloading"), having multiple functions/methods with the same name that are distinguished by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found