-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: calledOnce is not defined #28
Comments
I am a regular user of hot reloading and I have not experienced this issue. There is something funny going in on that hot reload. Take a look at the code there is not much, and I cannot see how a variable ( This feels like it is an issue with the hot reloader. Can you please post an example of how you are using memoizeOne? Cheers |
We're using it in constructor: export default class CourseSearch extends Component {
constructor() {
super();
// Re-rendering performance optimization.
// But has a bug with `react-hot-loader`.
this.getDateFilterMinDateRefinement = memoize(this.getDateFilterMinDateRefinement);
this.getInstitutionFilterForSpecificInstitution = memoize(this.getInstitutionFilterForSpecificInstitution);
}
getDateFilterMinDateRefinement = min => ({ min })
getInstitutionFilterForSpecificInstitution = institution => [institution]
render() {
return (
<InstantSearchExcludePast
...
defaultRefinement={this.getDateFilterMinDateRefinement(today + addDropDateShift)}
today={today + addDropDateShift} />
<InstantSearchMultiSelectList
...
defaultRefinement={institution ? this.getInstitutionFilterForSpecificInstitution(institution) : undefined} />
)
}
} The point is that while props stay the same by reference React doesn't re-render (probably, or maybe it still does). I'll close this for now, as it seems like an our way of writing code + hot-loader + memoizeOne all combined in a single use case. |
I'm encountering exactly the same problem, do you find a solution @catamphetamine |
No, I just dropped ‘memoize-one’ in favour of hot-reload.
…On Thu, 6 Sep 2018 at 15:35, Neo ***@***.***> wrote:
I'm encountering exactly the same problem, do you find a solution
@catamphetamine <https://github.com/catamphetamine>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#28 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAdH7-KmVyg-k9YiHtUC8islBxyOmFx8ks5uYRZ6gaJpZM4VwpiE>
.
|
Right now I have to workaround like this |
So if this problem still exists, I'd suggest to reopen the issue, no matter what's the root cause, but we have to find the reason |
It looks like this is the cause: gaearon/react-hot-loader#978 |
Happy to reopen but it looks like the issue is not with this library, but with the hot reloaders ability to deal with higher order functions |
@alexreardon thanks for the context, it's really helpful, I can confirm the error is gone after upgrade Thanks for your great library 👍 , I think it's good to close now, but change the label to |
When used with
react-hot-loader
it throws this errorgetDateFilterMinDateRefinement()
is a function that's wrapped inmemoize()
.The error happens, for example, when the component containing memoization is removed from code and then hit "Save" so that it hot-reloads.
The text was updated successfully, but these errors were encountered: