Skip to content

Conversation

strmer15
Copy link

We were switching from react-helmet to react-helmet-async, but our production application threw errors at runtime (effectively shutting our website down) because of a misplaced <Helmet> tag outside of the <HelmetProvider>. This caused react-helmet-async to throw the error Cannot read properties of undefined (reading 'add').

While that's an obvious problem that can be addressed separately, it would help users who are switching to check for a missing context beforehand and not attempt to reference objects that are possibly undefined. This change checks to see if helmetInstances is truthy and, if not, logs a trace to the console and returns immediately. This way, users can be aware of their code not behaving correctly while still maintaining a running website.

@strmer15
Copy link
Author

@staylor Could you review this and let me know if it can make into the next release? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant