{"id":7935,"date":"2020-07-11T18:40:47","date_gmt":"2020-07-11T18:40:47","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=7935"},"modified":"2020-07-11T18:40:47","modified_gmt":"2020-07-11T18:40:47","slug":"storybook-render-decorator","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/storybook-render-decorator\/","title":{"rendered":"Storybook render decorator"},"content":{"rendered":"<p>Storybook have a bunch of really useful decorators. <\/p>\n<p>This one is useful to see when changes, either data, state or properties cause re-rendering of our React UI. In some cases it may be that a change should not cause a subcomponent to render, with this decorator we can see what caused the render to occur (or at least help point us towards possible reasons).<\/p>\n<p>We need to install the add-on, like this<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nyarn add -D storybook-addon-react-renders\r\n<\/pre>\n<p>and we just add code like this<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nimport { withRenders } from &quot;storybook-addon-react-renders&quot;;\r\n\r\nstoriesOf(&quot;Some Component Test&quot;, module)\r\n  .addDecorator(withRenders)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Storybook have a bunch of really useful decorators. This one is useful to see when changes, either data, state or properties cause re-rendering of our React UI. In some cases it may be that a change should not cause a subcomponent to render, with this decorator we can see what caused the render to occur [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[243,251],"tags":[],"class_list":["post-7935","post","type-post","status-publish","format-standard","hentry","category-react","category-storybook"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=7935"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7935\/revisions"}],"predecessor-version":[{"id":8429,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/7935\/revisions\/8429"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=7935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=7935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=7935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}