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: React text node support #11429

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

Controls: React text node support #11429

shilman opened this issue Jul 6, 2020 · 6 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, in the short term. Long term, we should support JSX #11428

@shilman shilman added this to the 6.0 rc milestone Jul 6, 2020
@shilman shilman changed the title Controls: React node support Controls: React text node support Jul 6, 2020
@shilman shilman self-assigned this Jul 6, 2020
@shilman shilman modified the milestones: 6.0 rc, 6.0 args Jul 13, 2020
@shilman shilman modified the milestones: 6.0 args, 6.0 Jul 30, 2020
@shilman shilman modified the milestones: 6.0, 6.0.x, 6.1 args Aug 11, 2020
@shilman shilman removed the tracked label Aug 13, 2020
@rodoabad
Copy link

rodoabad commented Sep 1, 2020

Any temporary fix for this?

@shilman
Copy link
Member Author

shilman commented Sep 3, 2020

You can also set argTypes: { fieldName: { control: 'text' } } and then you edit it simply but the child will always be a string

@stale
Copy link

stale bot commented Oct 4, 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!

@stale stale bot added the inactive label Oct 4, 2020
@stale stale bot removed the inactive label Oct 4, 2020
@monolithed
Copy link

monolithed commented Oct 12, 2020

Is there any workaround for this one?

UPD:

{
    argTypes: {
        child: {
            table: {
                type: {
                    summary: 'React.ReactNode'
                }
            },
            control: {
                type: 'select',
                options: {
                    default: [ ],
                    withChild: [
                        <SomeComponent />
                    ]
                }
            }
        }
    }
}

@shilman shilman modified the milestones: 6.1 args, 6.2 args Oct 13, 2020
@trumbitta
Copy link

    argTypes: {
        child: {
            table: {
                type: {
                    summary: 'React.ReactNode'
                }
            },
            control: {
                type: 'select',
                options: {
                    default: [ ],
                    withChild: [
                        <SomeComponent />
                    ]
                }
            }
        

Nice workaround! But how do you pass props to that component?

The value of my withChild is supposed to be ({ label, destination }) => <NavLinkStyled to={destination}>PREFIX - {label}</NavLinkStyled> but it doesn't work

@ghengeveld
Copy link
Member

Because JSX isn't serializable (by telejson), such values cannot be used as args. As of Storybook 6.2, you can use a mapping.

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

5 participants