13 likes
·
114 reads
3 comments
As simple as that to configure the next/font with your storybook
Hi Borris, thanks for this very nice blog post! If I may suggest a simple improvement, since this decorator is run before rendering each Story, you can add, out of the preview scope, a boolean variable that becomes true once the classes have been added to the body. You can then check the value of this variable on subsequent runs of the decorator and return early if the classes have already been added. Even if the cost of a classList.add isn't that important, this would help your technique scale better as the number of Stories grows.
Definitely interesting idea, will definitely try it out. The story rendering part should be isolated, so it should be new afresh on every story - hence I will have to check if the class is being reset or not on each story rendering. Thanks for the suggestion - will keep up to date with this as well after trying it out.