I'm trying to pass some data from React to Javascript. How would I pass them to the window object or access the React states from the window? Our analytics code (non-React) needs to have access to some of the data within React.
<Helmet>
<script type="text/javascript" >
var userId = 'user_123456789' // This works
var userId = {userId} // This doesn't work
</script>
<script src={withPrefix('analytics')} type="text/javascript" />
</Helmet>
Error
TypeError: tag[primaryAttributeKey].toLowerCase is not a function
(anonymous function)
node_modules/react-helmet/es/Helmet.js:253
250 | return false;
251 | }
252 |
> 253 | var value = tag[primaryAttributeKey].toLowerCase();
254 |
255 | if (!approvedSeenTags[primaryAttributeKey]) {
256 | approvedSeenTags[primaryAttributeKey] = {};
For anyone wanting the answer to this, I did this: