Skip to content

Fix recursion with react elements #883

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

7rulnik
Copy link

@7rulnik 7rulnik commented Apr 13, 2025

It fixes #681

The bug was introduced in #619.

It's not a first time since we encounter this issue, see #307 and especially #312 (comment).

I faced it in storybook and managed to reproduce it using this story:

import { Meta, Story } from "@storybook/react";
import { Buttons, ButtonsProps } from "./Buttons";

export default {
  title: "Components/Buttons",
  component: Buttons,
} as Meta<ButtonsProps>;

export const Default: Story<ButtonsProps> = ({}: ButtonsProps) => (
  <div
    buttons={[
      {
        foo: "bar",
        jsx: <div key="1">Button in array</div>, // this leads to OOM
      },
    ]}
  />
);

but couldn't write test case for it. I tried to reproduce it using code snippet from #312 (comment) with latest react and react-element-to-jsx-string but couldn't for some reasons.

So this is why I decided to add test directly to src/formatter/sortObject.spec.js

It also should fix storybookjs/storybook#16827.

I suggest to backport it to v15 because people mostly use react 18 right now:
image

@7rulnik 7rulnik marked this pull request as ready for review April 13, 2025 18:04
@7rulnik 7rulnik marked this pull request as draft April 14, 2025 07:26
@7rulnik 7rulnik marked this pull request as ready for review April 14, 2025 09:36
@7rulnik
Copy link
Author

7rulnik commented Apr 16, 2025

@armandabric could you take a look please?

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

Successfully merging this pull request may close these issues.

14.3.3 causes crashes in Storybook Out-of-memory in development mode.
2 participants