Skip to content
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

It seems that react-helmet-async doesn't keep the order of the scripts added in the jsx #187

Open
meesfrenkelfrank opened this issue Jan 17, 2023 · 0 comments

Comments

@meesfrenkelfrank
Copy link

I am using react-helmet-async to add three scripts in order to the HEAD element on a specific page in my React app:

import React from 'react';

import { Helmet } from 'react-helmet-async';

import { Props } from './Advertising.types';

const MyComponent = ({ id, type }: Props) => {
  return (
    <Helmet>
  <script>{`var myData = { "id":"${id}", "type":"${type}" };`}</script>
  <script src="https://thirdparty.com/js/main.js" />
  <script
    type="application/javascript"
    src="thirdparty2.com/main.js"
  />
</Helmet>
  );
};

When navigating to a page the first <script> tag is rendered as last in the dom. But it should be rendered first. So it's not respecting the order, added in the jsx. What could be the issue?

(When refreshing the page manually the script tags are in correct order).

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

No branches or pull requests

1 participant