(#1736) Adds Ability to re-render a story programatically in react

Also adds support for redux DevTools in react/client
This commit is contained in:
Dan Green 2017-12-11 17:52:28 -05:00
parent cb262d483d
commit 98fa5cd117
2 changed files with 17 additions and 2 deletions

View File

@ -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,

View File

@ -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) {
@ -53,3 +59,5 @@ const renderUI = () => {
};
reduxStore.subscribe(renderUI);
export const forceReRender = () => renderUI();