Skip to content

getting to work in NextJS? #151

Description

@a-rbsn

Hey there — such a great tool for making text more visually appealing online.

I have used this in non-React based sites but am struggling to get it to work within React/NextJS/Gatsby based sites.

In Next I have tried this in my _app.js:

      <Script src='/balancetext.js' strategy='beforeInteractive' />
      <Script
        id='balance-text-script'
        strategy='afterInteractive'
        dangerouslySetInnerHTML={{
          __html: `
            balanceText();
          `,
        }}
      />

and I have also tried this in my pages:

import * as balanceText from "balance-text";
...
  useEffect(() => {
    balanceText();

    return () => {};
  }, []);

But none of these appear to work, even with the above, if I visit my site in browser and do balanceText(); in console, it picks up the command but isn't applied to any text that has the balance-text class, just gets completely ignored, any ideas?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions