How to use the @storybook/client-api.getQueryParams 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 storybookjs / storybook / addons / knobs / src / KnobManager.js View on Github external
/* eslint no-underscore-dangle: 0 */
import { navigator } from 'global';
import escape from 'escape-html';

import { getQueryParams } from '@storybook/client-api';

import KnobStore from './KnobStore';
import { SET } from './shared';

import { deserializers } from './converters';

const knobValuesFromUrl = Object.entries(getQueryParams()).reduce((acc, [k, v]) => {
  if (k.includes('knob-')) {
    return { ...acc, [k.replace('knob-', '')]: v };
  }
  return acc;
}, {});

// This is used by _mayCallChannel to determine how long to wait to before triggering a panel update
const PANEL_UPDATE_INTERVAL = 400;

const escapeStrings = obj => {
  if (typeof obj === 'string') {
    return escape(obj);
  }
  if (obj == null || typeof obj !== 'object') {
    return obj;
  }