-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Circular references in React prop data causes stack overflow error in v6 #12747
Circular references in React prop data causes stack overflow error in v6 #12747
Comments
Thanks for the repro! As a temporary workaround you should be able to set the |
duplicate repro from @arcanis import React from 'react';
export default {
title: `Something`,
};
function TestComponent() {
return <>Hello World</>;
}
const selfReferencing: { self?: any } = {};
selfReferencing.self = selfReferencing;
export const Breaks = (args: any) => {
return (
<>
<TestComponent thisPropDoesntEvenExist={selfReferencing} />
</>
);
}; |
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! |
Hi @shilman ! This workaround seems not to work with Is there maybe a different approach I can take? I'm having this same issue with several stories that I need to solve. Thanks! |
I also face this issue using My story looks like this. import React from 'react'
import { Story, Meta } from '@storybook/react/types-6-0'
import { FormProvider, useForm, useFormContext } from 'react-hook-form'
import { Form } from 'react-bootstrap'
export default {
title: 'FormFields/Test',
component: TestInput
// This is a workaround for the issue regarding "Maximum call stack size exceeded"
// See https://github.com/storybookjs/storybook/issues/12747
//
// parameters: { docs: { source: { type: 'code' } } }
} as Meta
const TestInput = () => {
const { register } = useFormContext()
return (
<Form.Control
name='testFld1'
type='text'
ref={register({ required: 'Dies ist ein Pflichtfeld.' })}
/>
)
}
const Template: Story = (args) => {
return <TestInput />
}
export const Empty = Template.bind({})
Empty.decorators = [
(Story) => {
const rhFormMethods = useForm()
const onSubmit = (data) => console.log(data)
return (
<FormProvider {...rhFormMethods}>
<form noValidate onSubmit={rhFormMethods.handleSubmit(onSubmit)}>
<Story />
<input type='submit' />
</form>
</FormProvider>
)
}
]
Empty.args = {} |
@shilman Will circular references be working again in 6.2? |
I had the same issue with react-hook-form and storybook. The "Maximum callstack exceeded" error was resolved by setting docs.source.type to "code" as described. (Although I have no idea what other impact this may have) I have read elsewhere that for react-hook-form, the issue may be due to a react Another report of this issue between react-hook-form and storybook - https://www.gitmemory.com/issue/react-hook-form/react-hook-form/4449/803590957 |
The problem is in the I've just prepared a couple of other PRs for this package but as far as I can tell it is a little bit abandoned at the moment. This one wouldn't be a hard problem to fix and I might do it as well - if they merge those other PRs. At the moment investing time in that seems like a possible waste so I'm waiting to see if there is any activity in that project. |
And here is the fix for the issue: algolia/react-element-to-jsx-string#660 . At least for the one initially reported by @jonrimmer here. |
Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.16 containing PR #16407 that references this issue. Upgrade today to the
|
This is very much still a problem @shilman. Only fix I've been able to ascertain is using: parameters: {
docs: {
source: {
type: 'code'
}
}
} I cannot find what this does anywhere in the docs... |
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given. |
Setting the By I still don't understand what's the difference between |
Describe the bug
If a data structure with a circular reference is supplied a prop to a React component, Storybook will error with a
Maximum call stack size exceeded
error.To Reproduce
Button
story created bysb init
:Opening the story will produce an error of the form:
Expected behavior
The Story should work without errors.
Code snippets
A simple repro repo is here:
https://github.com/jonrimmer/storybook-v6-is-broken
System
Additional context
This worked fine in v5. The error seems to be happened because Storybook is trying to use react-element-to-jsx-string to serialize the story. This will obviously not work with many data structures.
The text was updated successfully, but these errors were encountered: