{"action":"created","issue":{"url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/31","repository_url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs","labels_url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/31/comments","events_url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/31/events","html_url":"https://github.com/kadirahq/storybook-addon-knobs/issues/31","id":177591099,"number":31,"title":"Using knobs in global decorators","user":{"login":"firebait","id":140254,"avatar_url":"https://avatars.githubusercontent.com/u/140254?v=3","gravatar_id":"","url":"https://api.github.com/users/firebait","html_url":"https://github.com/firebait","followers_url":"https://api.github.com/users/firebait/followers","following_url":"https://api.github.com/users/firebait/following{/other_user}","gists_url":"https://api.github.com/users/firebait/gists{/gist_id}","starred_url":"https://api.github.com/users/firebait/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firebait/subscriptions","organizations_url":"https://api.github.com/users/firebait/orgs","repos_url":"https://api.github.com/users/firebait/repos","events_url":"https://api.github.com/users/firebait/events{/privacy}","received_events_url":"https://api.github.com/users/firebait/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-17T17:01:40Z","updated_at":"2016-09-17T19:04:46Z","closed_at":null,"body":"This is more like a question but I have a use case in which I would like to use knobs at the global decorator level, so I added the following code to my `config.js` like this:\r\n```\r\naddDecorator((story) => (\r\n  <ThemeProvider theme={select('Theme', themes, 'Light')}>\r\n    {story()}\r\n  </ThemeProvider>\r\n));\r\n```\r\nThe above code fails on this error becuase I think because the knob store is not been created yet:\r\n```\r\nCannot read property 'get' of null\r\nTypeError: Cannot read property 'get' of null\r\n    at KnobManager.knob (webpack:///~/@kadira/storybook-addon-knobs/dist/KnobManager.js:50:35)\r\n    at select (webpack:///~/@kadira/storybook-addon-knobs/dist/index.js:47:18)\r\n    at eval (webpack:///:21:46)\r\n    at eval (webpack:///~/@kadira/storybook/dist/client/preview/client_api.js:95:20)\r\n    at renderMain (webpack:///~/@kadira/storybook/dist/client/preview/render.js:85:31)\r\n    at renderPreview (webpack:///~/@kadira/storybook/dist/client/preview/render.js:101:10)\r\n    at Array.renderUI (webpack:///~/@kadira/storybook/dist/client/preview/index.js:89:26)\r\n    at Object.dispatch (webpack:///~/redux/lib/createStore.js:186:19)\r\n    at ConfigApi._renderMain (webpack:///~/@kadira/storybook/dist/client/preview/config_api.js:48:24)\r\n    at render (webpack:///~/@kadira/storybook/dist/client/preview/config_api.js:66:17)\r\n```"},"comment":{"url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/comments/247798123","html_url":"https://github.com/kadirahq/storybook-addon-knobs/issues/31#issuecomment-247798123","issue_url":"https://api.github.com/repos/kadirahq/storybook-addon-knobs/issues/31","id":247798123,"user":{"login":"roonyh","id":3872221,"avatar_url":"https://avatars.githubusercontent.com/u/3872221?v=3","gravatar_id":"","url":"https://api.github.com/users/roonyh","html_url":"https://github.com/roonyh","followers_url":"https://api.github.com/users/roonyh/followers","following_url":"https://api.github.com/users/roonyh/following{/other_user}","gists_url":"https://api.github.com/users/roonyh/gists{/gist_id}","starred_url":"https://api.github.com/users/roonyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roonyh/subscriptions","organizations_url":"https://api.github.com/users/roonyh/orgs","repos_url":"https://api.github.com/users/roonyh/repos","events_url":"https://api.github.com/users/roonyh/events{/privacy}","received_events_url":"https://api.github.com/users/roonyh/received_events","type":"User","site_admin":false},"created_at":"2016-09-17T19:04:46Z","updated_at":"2016-09-17T19:04:46Z","body":"Or this way which looks slightly cleaner.\r\n```js\r\naddDecorator(withKnobs) // add withKnobs\r\naddDecorator((story) => {\r\n\r\n    const content = story() // call story early so knob store is created before `select` call\r\n\r\n    return (\r\n      <ThemeProvider theme={select('Theme', themes, 'Light')}>\r\n        {content}\r\n      </ThemeProvider >\r\n    );\r\n  }\r\n);\r\n```"}}
{"actor":{"display_login":"roonyh"}}