mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-12 04:37:06 +03:00
10bf7bc084
* chore(*): upgrade prettier * chore(*): upgrade prettier
29 lines
668 B
JavaScript
29 lines
668 B
JavaScript
import React from 'react';
|
|
import addons from '@storybook/addons';
|
|
import { EVENT_ID_DATA, DEFAULT_THEME_STATE } from './constant';
|
|
import { Container } from '../../src';
|
|
|
|
const channel = addons.getChannel();
|
|
|
|
class Theme extends React.Component {
|
|
state = DEFAULT_THEME_STATE;
|
|
|
|
componentDidMount() {
|
|
channel.on(EVENT_ID_DATA, this.onChannel);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
channel.removeListener(EVENT_ID_DATA, this.onChannel);
|
|
}
|
|
|
|
onChannel = (state) => {
|
|
this.setState(state);
|
|
};
|
|
|
|
render() {
|
|
return <Container themeData={this.state}>{this.props.children}</Container>;
|
|
}
|
|
}
|
|
|
|
export const withTheme = (story) => <Theme>{story()}</Theme>;
|