react: Apostrophes in strings are rendered incorrectly
See original GitHub issueDescribe the bug
Apostrophes are rendered as '
instead of as '
.
To Reproduce Steps to reproduce the behavior:
- Go to https://storybooks-official.netlify.com/?path=/story/addons-knobs-withknobs--tweaks-static-values
- Click on Knobs
- Change Name from “Storyteller” to “Mc’Storyteller”
- See error rendered on the Canvas:
My name is Mc'Storyteller
Expected behavior
Canvas should be rendered with My name is Mc'Storyteller
Code snippets
Any string
used in JSX containing an apostrophe will be rendered incorrectly.
e.g.
render() {
const string = "I'm wrong";
return <>{string}</>;
}
System:
System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.117
Firefox: 70.0.1
Safari: 13.0.4
npmPackages:
@storybook/addon-actions: ^5.2.8 => 5.2.8
@storybook/addon-knobs: ^5.2.8 => 5.2.8
@storybook/react: ^5.2.8 => 5.2.8
Additional context
Apostrophes in JSX text nodes will render correctly (from what I’ve seen so far):
render() {
return <>I'm right</>;
}
So this issue might only apply to strings that are used within JSX elements (and not to JSX text nodes directly).
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Apostrophe doesn't render - Forums - CSS-Tricks
I'm having difficulty getting an apostrophe in text to render correctly. ... Thanks — I went in to the html and saw that...
Read more >React JSX, how to render text with a single quote? Example ...
Render as a JS string literal (with double-quotes): return (<p>{"I've seen the movie."}</p>) ... or use the HTML entity for an apostrophe, '...
Read more >Should I escape the Apostrophe ( ' ) character with its HTML ...
"If your apostrophe belongs to content, escape it." - This would seem to be incorrect (as if missing the word "don't"). If the...
Read more >REACT – Simple Intro Component Not Rendering?
The problem is that there are a few gotchas that make working with components difficult for those new to React.
Read more >React.js Frequently Faced Problems | Codementor
If you meant to render a React component, start its name with an uppercase ... are different from strings created with single quotes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi everyone! Seems like there hasn’t been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don’t have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
@cellog we’ve released
addon-controls
in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replaceaddon-knobs
long term.PRs on addon-knobs still welcomed