question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react: Apostrophes in strings are rendered incorrectly

See original GitHub issue

Describe the bug Apostrophes are rendered as ' instead of as '.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://storybooks-official.netlify.com/?path=/story/addons-knobs-withknobs--tweaks-static-values
  2. Click on Knobs
  3. Change Name from “Storyteller” to “Mc’Storyteller”
  4. 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:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
stale[bot]commented, Apr 1, 2020

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!

0reactions
shilmancommented, Sep 22, 2020

@cellog we’ve released addon-controls in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term.

PRs on addon-knobs still welcomed

Read more comments on GitHub >

github_iconTop 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, &apos;...
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found