storybookjs / addon-jsx

This Storybook addon show you the JSX / template of the story
https://storybooks-addon-jsx.netlify.com
MIT License
235 stars 32 forks source link

React Hooks #84

Open florinesueur opened 5 years ago

florinesueur commented 5 years ago

Only when I add addon-jsx, I have this problem. Screenshot_2019-08-10 Storybook

button.tsx

import './button.style.css';
import * as React from 'react';

interface Props {
    /**
     * Text for the button
     */
    text: String;
}

export const ButtonNew = ({ text }: Props) => {
    const [value, setValue] = React.useState('...');

    console.log(value);

    return (
        <div>
            <div className="green">
                {text}
                <input type="text" value={value} onChange={({ target }) => setValue(target.value)} />
            </div>
        </div>
    );
};

ButtonNew.defaultProps = {
    text: 'ok',
};

button.stories.tsx

import * as React from 'react';
import { setAddon, storiesOf } from '@storybook/react';
import JSXAddon from 'storybook-addon-jsx';

setAddon(JSXAddon);

import { ButtonNew } from '../src/components/button/button';

storiesOf('Administrator/Button', module).addWithJSX('custom', () => <ButtonNew />);

Did you have the same issue?

Gabrielmtn commented 5 years ago

Did you find a solution @florinesueur?

florinesueur commented 5 years ago

@Gabrielmtn no, I did not find a solution and I put this project in standby.

hipstersmoothie commented 4 years ago

Can you try this again? my projects use many hooks and this addon works fine