ESLint react/no-unescaped-entities on an apostrophe or quote in JSX
react/no-unescaped-entitiesShort answer
The rule react/no-unescaped-entities forbids four characters in JSX text: > " ' and }. Replace each with its entity (' " > }) or write the text as a JavaScript string inside braces. If your team wants fewer characters blocked, set the forbid option instead of turning the rule off.
Fix it fast
1Find out which cause you have
Run ESLint on the file. The report gives the line and the character that triggered the rule.
npx eslint src/pages/About.jsx2Match what you see, then jump to its fix
- 1
react/no-unescaped-entities on text such as <p>Don't stop</p>A raw apostrophe or double quote in JSX textFix - 2
The same rule on text like <p>a > b</p> or code samples with closing bracesA raw > or } in JSX textFix - 3
Hundreds of reports for apostrophes in long copyThe default list is stricter than your team wantsFix
- 1
What does the error look like?
react/no-unescaped-entities
Cause 1 of 3
A raw apostrophe or double quote in JSX text
1Check
Look at the reported line. The character sits in text between tags, not in an attribute or an expression.
grep -rn "<p>[^<]*'" src/2Fix
Use an HTML entity, or put the string in a JavaScript expression. Both render the same character.
<p>Don't stop</p>
<p>She said "yes"</p>
<p>{"Don't stop"}</p>3Verify
ESLint reports nothing for the line and the page shows the apostrophe.
npx eslint src/pages/About.jsxConfirmed by github.com
Cause 2 of 3
A raw > or } in JSX text
1Check
The rule also forbids > and }. It does not check < or {, because those are already syntax errors inside a tag.
grep -rn '<p>[^<]*[>}]' src/2Fix
Use > and }, or a string in braces.
<p>a > b</p>
<code>{'}'}</code>3Verify
Run ESLint again.
npx eslint src/Confirmed by github.com
Cause 3 of 3
The default list is stricter than your team wants
1Check
The forbid option replaces the default character list. Without it, all four characters are checked.
grep -n 'no-unescaped-entities' .eslintrc* eslint.config.*2Fix
List only the characters you still want blocked.
"react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }]3Verify
ESLint passes on the apostrophes, and still flags > and }.
npx eslint src/Confirmed by github.com
How do I stop it coming back?
- Write text with a typographic apostrophe (the right single quote) in content files, or keep copy in strings.
- Run ESLint in the editor so the report appears while you type.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Astro Code component fails inside a React component
Astro components cannot be rendered directly via function call
Astro components such as Code only exist on the server and render static HTML.
2 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
How to catch and handle a 422 from Axios in a Redux thunk
action.error.message is 'Rejected' and action.payload is undefined
A 422 means the server read the request but cannot process its content, so repeating it unchanged fails again.
4 causes, each with a fixWeb apps
axios gets 429 Too Many Requests from a React app
429 (Too Many Requests)
A 429 comes from the server or an API gateway, not from axios: your client sent too many requests in a window.
4 causes, each with a fixWeb apps
Axios request is not cancelled when a React component unmounts
A cancelled request is logged as an error in the catch block
Axios cancels a request when you pass it an AbortSignal and later call abort() on its controller.
4 causes, each with a fix