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

Controls: JSX support #11428

Open
shilman opened this issue Jul 6, 2020 · 3 comments
Open

Controls: JSX support #11428

shilman opened this issue Jul 6, 2020 · 3 comments

Comments

@shilman
Copy link
Member

shilman commented Jul 6, 2020

Currently React nodes, such as children, show a JSON object editor by default. They should show a text editor instead that supports full JSX editing.

@ronny1020
Copy link

ronny1020 commented Nov 25, 2024

I just found a walkaround before this issue is supported. It can be set individually in the preview.tsx file while the ReactNode prop shares the same name as children. should work properly.

// .storybook/preview.tsx

import { Preview } from '@storybook/react';
import '../src/index.css';

const OVERWRITE_REACT_NODE_TO_STRING = {
  control: 'text',
  description: 'Overwritten ReactNode type object for Storybook.',
} as const;

const preview: Preview = {
  argTypes: {
    children: OVERWRITE_REACT_NODE_TO_STRING,
    anyOtherProp: OVERWRITE_REACT_NODE_TO_STRING,
  },
 //  ...othersettings
};

export default preview;

It can also be set in the component.stories.tsx file if the ReactNode prop name is only used in a specific component.

@thumbsupep
Copy link

@ronny1020 that workaround still doesn't support interpolating jsx from the text control

@ronny1020
Copy link

@ronny1020 that workaround still doesn't support interpolating jsx from the text control

It's just a walkaround to show text control instead of the object editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants