Skip to content

Commit

Permalink
(#1736) Adds Ability to re-render a story programatically in react
Browse files Browse the repository at this point in the history
Also adds support for redux DevTools in react/client
  • Loading branch information
dangreenisrael committed Dec 11, 2017
1 parent cb262d4 commit 98fa5cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/react/src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import deprecate from 'util-deprecate';
import { action as deprecatedAction } from '@storybook/addon-actions';
import { linkTo as deprecatedLinkTo } from '@storybook/addon-links';

export { storiesOf, setAddon, addDecorator, configure, getStorybook } from './preview';
export {
storiesOf,
setAddon,
addDecorator,
configure,
getStorybook,
forceReRender,
} from './preview';

export const action = deprecate(
deprecatedAction,
Expand Down
10 changes: 9 additions & 1 deletion app/react/src/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const isBrowser =
!(navigator.userAgent.indexOf('Node.js') > -1);

const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
/* eslint-disable no-underscore-dangle */
const reduxStore = createStore(
reducer,
window.__REDUX_DEVTOOLS_EXTENSION__ &&
window.__REDUX_DEVTOOLS_EXTENSION__({ name: 'Storybook Preview', instanceId: 'sbPreview' })
);
/* eslint-enable */
const context = { storyStore, reduxStore };

if (isBrowser) {
Expand Down Expand Up @@ -53,3 +59,5 @@ const renderUI = () => {
};

reduxStore.subscribe(renderUI);

export const forceReRender = () => renderUI();

0 comments on commit 98fa5cd

Please sign in to comment.