You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, we can inspect the output of decorator(...) and see if it's
A renderable (an React Element or an object in vue). (the old decorator case)
Another function (the new story). (the new wrapper case).
In case 2, we can then just execute it.
So the new code looks like:
constfn=decorators.reduce((decorated,decorator)=>context=>{if(decorator.length===2){// old casereturndecorator(()=>decorated(context),context);}constnewDecorated=decorator(()=>decorated(context));// new caseif(typeofnewDecorated===function){returnnewDecorated(context);}// old case, decorator doesn't consider contextreturnnewDecorated;},getStory);
Phew! Confusing. But I think it works.
The text was updated successfully, but these errors were encountered:
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. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks!
Hey there, it's me again! I am going to help our maintainers close this issue so they can focus on development efforts instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!
As per @shilman in https://gist.github.com/shilman/792dc25550daa9c2bf37238f4ef7a398:
We are moving to a "wrapper" style API for addons/decorators:
Which can be used like:
However, currently the decorator API takes something slightly different:
It's conceptually the same, but different in practice.
Proposal:
In 3.3: Allow
addDecorator
to take bothdecorator
andwrapper
style functions.In 3.4 (or sooner): deprecate the
decorator
style.In 4.0: only allow wrappers.
Implementation.
Decorators are applied (in each app layer) in a line like this:
However, we can inspect the output of
decorator(...)
and see if it'sobject
in vue). (the old decorator case)In case 2, we can then just execute it.
So the new code looks like:
Phew! Confusing. But I think it works.
The text was updated successfully, but these errors were encountered: