Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX variable interpolation doesn't work in <option> children #105

Closed
jbachhardie opened this issue Jan 24, 2022 · 1 comment
Closed

JSX variable interpolation doesn't work in <option> children #105

jbachhardie opened this issue Jan 24, 2022 · 1 comment
Assignees
Labels
bug Something isn't working design-system

Comments

@jbachhardie
Copy link

jbachhardie commented Jan 24, 2022

Describe the bug
If the content of an <option> tag is constructed via JSX interpolation, only the first fragment ends up rendered in the HTML

To Reproduce
Steps to reproduce the behavior:

  1. Insert a Select with options like the following
const TestView = () => {
  const stringVariable = "foo";
  return (
    <ContextView title="Get started with Stripe Apps">
      <Select label="Test select">
        <option value="first">JSX concatenation of {stringVariable}</option>
        <option value="second">{`string concatenation of ${stringVariable}`}</option>
      </Select>
    </ContextView>
  );
};
  1. See that for the first <option> the rendered text is "JSX concatenation of " whereas the second one renders the full expected value of "string concatenation of foo"

Expected behavior
Both forms of interpolation should result in the same HTML, as they do in vanilla React

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 96
@jbachhardie jbachhardie added bug Something isn't working needs-triage labels Jan 24, 2022
@jbachhardie jbachhardie changed the title JSX variable interpolation doesn' JSX variable interpolation doesn't work in <option> children Jan 24, 2022
@jlongster-stripe
Copy link

This is expected. It's how React works: facebook/react#13465

If you just did <option value="first">{stringVariable}</option> you'd see the value. But otherwise it creates a children tree and React doesn't support that with option. Apparently this is fixed in React 18 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working design-system
Projects
None yet
Development

No branches or pull requests

3 participants