storybook
storybook copied to clipboard
Source Doc Block - JavaScript not formatting properly
When building a docs page and using <Source />
with JavaScript via the code
prop and using a template literal, it breaks when there's a line break in a specific location.
For example, here there is a line break above return
,
<Source
language="javascript"
dark
format={true}
code={dedent`
const ParentComponent = () => {
const [isOpen, setIsOpen] = useState(false);
const handleClick = () => {
setIsOpen(true);
};
return (
<>
<Button onClick={handleClick}>Controlled toast</Button>
<Toast isOpen={isOpen} onOpenChange={setIsOpen} />
</>
); } `}
/>
Which leads to the error:
However, when removing the line break, it renders properly.
If the line break is right below return
, it still renders properly.
Note: This happens with or without dedent
.
Cheers