storybook-addon-react-live-edit icon indicating copy to clipboard operation
storybook-addon-react-live-edit copied to clipboard

Need documentation for using with @storybook/react v5

Open tabrez96 opened this issue 5 years ago • 5 comments

How to configure it globally for all stories in config.js using addDecorator while using it with @storybook/react v5+?

I have imported all stories in config.js like this: var stories = require.context('../src', true, /\.stories\.js$/);

tabrez96 avatar Sep 27 '19 08:09 tabrez96

Same here, i really liked this addon and would like to use it with the Component Story Format (CSF) of Storybook 5.2

jesus101037 avatar Oct 10 '19 22:10 jesus101037

I hope that this could support with CSF, too.

duckscofield avatar Jan 09 '20 03:01 duckscofield

So I guess this addon is not compatible with the newer versions of storybook? I cannot get it to work. It just always says "Editor Unavailable"

KevinVandy avatar Feb 21 '20 20:02 KevinVandy

Managed to get it working by doing the following, an example would be nice though

import React from "react";
import { setOptions, withLiveEdit , withLiveEditScope } from "storybook-addon-react-live-edit";
import {MyComponent} from "somewhere";

setOptions({presets: ['react']});
export default {
    component: MyComponent,
    title: "MyComponent",
    decorators: [_ => withLiveEditScope({React, MyComponent})(_, {React, MyComponent}) ]
}

export const LiveEditComponent = (_) => withLiveEdit("return <MyComponent name={'MyComponent X'} />")(_);

the setOptions({presets: ['react']}) can also be done ./storybook/preview.js

mojjy avatar Mar 09 '20 09:03 mojjy

Managed to get it working by doing the following, an example would be nice though

import React from "react";
import { setOptions, withLiveEdit , withLiveEditScope } from "storybook-addon-react-live-edit";
import {MyComponent} from "somewhere";

setOptions({presets: ['react']});
export default {
    component: MyComponent,
    title: "MyComponent",
    decorators: [_ => withLiveEditScope({React, MyComponent})(_, {React, MyComponent}) ]
}

export const LiveEditComponent = (_) => withLiveEdit("return <MyComponent name={'MyComponent X'} />")(_);

the setOptions({presets: ['react']}) can also be done ./storybook/preview.js

Thanks. Do you have a full example by any chance?

thoughtworks-tcaceres avatar Mar 31 '20 03:03 thoughtworks-tcaceres