No handling for Symbol-named JSX tags like React.StrictMode
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- frontend
Research direction
Start at src/formatter/formatReactElementNode.js around line 122 and reproduce the crash with an inline React.StrictMode element. Trace how the tag name is formatted, then verify that symbol-named tags produce a JSX string without crashing, including the React.StrictMode case.
Written by the indexing model from the issue text.
Description
In React, the built-in <React.StrictMode> tag is a symbol. Trying to generate JSX for any tags with Symbol-names crashes at the following line because there's no handling for symbols:
Please add proper handling so Storybook works with inline StrictMode (since apparently it's broken otherwise).
Even something simple like the following would more than suffice:
// ... ^^ also make displayName not a const
const {
filterProps,
maxInlineAttributesLineLength,
showDefaultProps,
sortProps,
tabStop,
} = options;
/////////////////////
if(typeof displayName === "symbol") {
displayName = displayName === Symbol.for('react.strict_mode')
? "React.StrictMode" : String(displayName)
}
/////////////////////
let out = `<${displayName}`;
let outInlineAttr = out;
let outMultilineAttr = out;
let containsMultilineAttr = false;
// ...
Sorry, I may eventually have time to make a PR, but if not, hopefully I've sufficiently identified the problem and the solution.
- Dominant language
- TypeScript
- Stars
- 519
- Forks
- 88
- Avg merge
- 3h 55m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from algolia/react-element-to-jsx-string
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
All issues in algolia/react-element-to-jsx-string
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
bug triage:in-progress
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
redhat-developer/rhdh-plugin-export-overlays#4845 · 1 comment ·
Maintainers usually reply within 1 day
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
cloudflare/workers-sdk#17159 ·
Maintainers usually reply within 1 day