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

[Bug] An issue when using addon-jsx globally #179

Open
EugeneGrinchakEmpeek opened this issue Dec 15, 2022 · 0 comments
Open

[Bug] An issue when using addon-jsx globally #179

EugeneGrinchakEmpeek opened this issue Dec 15, 2022 · 0 comments
Labels

Comments

@EugeneGrinchakEmpeek
Copy link

EugeneGrinchakEmpeek commented Dec 15, 2022

Describe the bug

Hi. I'm using a Storybook with NextJS app integration

There is an issue when using addon-jsx globally in my app.
The jsx output is not correct. It contains a redundant Storybook's wrapper

But it works correct if apply addon to the single story.

This may be similar to the issue #131

Steps to reproduce the behavior

preview.ts:

import { addDecorator } from '@storybook/react';
import { jsxDecorator } from 'storybook-addon-jsx';

export const decorators = [
  withI18next({ i18n, languages: { en: 'English', fr: 'French', de: 'German', es: 'Spanish' } }),
  Story => {
    return (
      <Suspense fallback="loading...">
        <Provider store={store}>
          <SnackbarProvider
            maxSnack={3}
            anchorOrigin={{
              vertical: 'bottom',
              horizontal: 'center',
            }}
          >
            <Story />
          </SnackbarProvider>
        </Provider>
      </Suspense>
    )
  },
  withStaticMarkup(),
];

addDecorator(jsxDecorator);

storybook-addon-jsx output:

<RouterContext.Provider
  value={{
    asPath: '/',
    back: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.back').apply(void 0, args);},
    beforePopState: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.beforePopState').apply(void 0, args);},
    events: {
      emit: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.events.emit').apply(void 0, args);},
      off: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.events.off').apply(void 0, args);},
      on: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.events.on').apply(void 0, args);}
    },
    isFallback: false,
    locale: undefined,
    pathname: '/',
    prefetch: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.prefetch').apply(void 0, args);return Promise.resolve();},
    push: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.push').apply(void 0, args);return Promise.resolve(true);},
    query: {},
    reload: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.reload').apply(void 0, args);},
    replace: function () {var args = [];for (var _i = 0; _i < arguments.length; _i++) {args[_i] = arguments[_i];}(0, addon_actions_1.action)('nextRouter.replace').apply(void 0, args);return Promise.resolve(true);},
    route: '/'
  }}
>
  <No Display Name
    abortSignal={[object AbortSignal]}
    applyLoaders={function applyLoaders(_x) {return _ref.apply(this, arguments);}}
    argTypes={{
      ariaLabel: {
        control: {
          type: 'text'
        },
        description: '',
        name: 'ariaLabel',
        table: {
          defaultValue: null,
          jsDocTags: undefined,
          type: {
            detail: undefined,
            summary: 'string'
          }
        },
        type: {
          name: 'string',
          required: false
        }
      },
      children: {
        control: {
          type: 'object'
        },
        description: 'The content of the button',
        name: 'children',
        table: {
          defaultValue: null,
          jsDocTags: undefined,
          type: {
            detail: undefined,
            summary: 'ReactNode'
          }
        },
        type: {
          name: 'other',
          required: false,
          value: 'ReactNode'
        }
      },
      ...

Expected behavior

A JSX output to be correct (without redundant Storybook's wrapper)

Screenshots and/or logs

Here is an JSX output example
jsx-addon-issue

Environment

  • OS: Windows
  • Node.js version: 16.18.0
@EugeneGrinchakEmpeek EugeneGrinchakEmpeek changed the title [Bug] [Bug] An issue when using addon-jsx globally Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant