Skip to content

Commit 7db4540

Browse files
fix first theme always being selected in ejected iframe view
1 parent 9cf6f5e commit 7db4540

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/WrapStory.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React from 'react';
22
import { ThemeProvider } from 'styled-components'
3+
import { getQueryParam } from '@storybook/client-api';
4+
5+
const currentThemeValueFromUrl = getQueryParam('currentTheme');
36

47
export default class WrapStory extends React.Component {
58

69
constructor(props) {
710
super(props)
811
const keys = Object.keys(props.themes)
9-
this.state = {theme: props.themes[keys[0]]}
12+
this.state = {theme: props.themes[currentThemeValueFromUrl || keys[0]]}
1013
this.updateState = this.updateState.bind(this)
1114
}
1215

0 commit comments

Comments
 (0)