adobe / adobe/balance-text

getting to work in NextJS?

Open
#151 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.4k
Forks
77
PR merge metrics
No merged PRs in 30d

Description

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
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?

Contributor guide

Open the contributing guide

Research direction

Start with the reported _app.js snippets and the page-level import/useEffect example, then reproduce the behavior in a Next.js, React, or Gatsby site using the balance-text class. Check whether balanceText() runs and whether it affects matching text; done means the documented integration works and the command applies balancing in the browser.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.