Closed abhijeetNmishra closed 8 years ago
Before you call rewind
, are you rendering a Helmet component with valid parameters? And are there any warnings or errors otherwise? Please refer to the README for various examples to get you started.
I can reproduce the same issue when there is no <Helmet />
render occurred in components on server rendering.
Returning a fallback for mapped state on rewind()
call would help to avoid the error. If rewind()
is wrapped by following code, rewind()
doesn't return undefined anymore:
static rewind = () => {
let mappedState = Component.rewind();
if (!mappedState) {
// provide fallback if mappedState is undefined
mappedState = mapStateOnServer({
title: "",
baseTag: "",
metaTags: "",
linkTags: "",
scriptTags: ""
});
}
return mappedState;
}
@sergesemashko Thx for the PR, will take a look soon.
@cwelch5, no problem. Myself and at least two more devs (one from referenced project and the person who submitted this issue) run into this problem. Adding a check in every project that might run into the same issue seems like a big code duplication to me :) I would suggest to prevent it from the package itself, or at least warn users about the check by docs or examples in case of empty state.
I am getting undefined for above code on server side ?