How to use the @storybook/client-api.getQueryParam function in @storybook/client-api

To help you get started, we’ve selected a few @storybook/client-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ticketmaster / storybook-styled-components / src / WrapStory.js View on Github external
import React from 'react';
import { ThemeProvider } from 'styled-components'
import { getQueryParam } from '@storybook/client-api';

const currentThemeValueFromUrl = getQueryParam('currentTheme');

export default class WrapStory extends React.Component {

  constructor(props) {
    super(props)
    const keys = Object.keys(props.themes)
    this.state = {theme: props.themes[currentThemeValueFromUrl || keys[0]]}
    this.updateState = this.updateState.bind(this)
  }

  componentDidMount() {
    this.props.channel.emit('storybook-styled-components:init', this.props.themes)
    this.props.channel.on('storybook-styled-components:update', this.updateState)
  }

  componentWillUnmount() {