Skip to content

Commit

Permalink
Fix an edge case where args/decorators could cause a React hook rules…
Browse files Browse the repository at this point in the history
… error. (#235)
  • Loading branch information
tajo committed Aug 26, 2022
1 parent 222ebcb commit 7aee108
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/flat-bears-rule.md
@@ -0,0 +1,5 @@
---
"@ladle/react": patch
---

Fix an edge case where args/decorators could cause a React hook rules error.
1 change: 0 additions & 1 deletion packages/ladle/lib/app/src/args-provider.tsx
Expand Up @@ -104,7 +104,6 @@ const ArgsProvider = ({
) {
return null;
}
if (!decorator) return component(props);
return decorator(() => component(props), {
globalState,
dispatch,
Expand Down
1 change: 1 addition & 0 deletions packages/ladle/lib/app/src/compose-enhancers.tsx
Expand Up @@ -9,6 +9,7 @@ export default function composeEnhancers(module: any, storyName: string) {
args: module[storyName].args,
argTypes: module[storyName].argTypes,
component: module[storyName],
decorator: (Component) => <Component />,
};
if (module[storyName] && Array.isArray(module[storyName].decorators)) {
funcs = [...funcs, ...module[storyName].decorators];
Expand Down

1 comment on commit 7aee108

@vercel
Copy link

@vercel vercel bot commented on 7aee108 Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ladle – ./

ladle-miksu.vercel.app
ladle.dev
ladle.vercel.app
ladle-git-main-miksu.vercel.app

Please sign in to comment.