Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addon-Knobs] Fixed addon for RN #1635

Merged
merged 3 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions addons/knobs/src/KnobManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import KnobStore from './KnobStore';
const PANEL_UPDATE_INTERVAL = 400;

export default class KnobManager {
constructor(channel) {
this.channel = channel;
constructor() {
this.knobStore = new KnobStore();
}

setChannel(channel) {
this.channel = channel;
}

knob(name, options) {
this._mayCallChannel();

Expand Down
6 changes: 4 additions & 2 deletions addons/knobs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import KnobManager from './KnobManager';
import { vueHandler } from './vue';
import { reactHandler } from './react';

const channel = addons.getChannel();
const manager = new KnobManager(channel);
const manager = new KnobManager();

export function knob(name, options) {
return manager.knob(name, options);
Expand Down Expand Up @@ -63,6 +62,9 @@ export function date(name, value = new Date()) {
// In 3.3, this will become `withKnobs`, once our decorator API supports it.
// See https://github.com/storybooks/storybook/pull/1527
function wrapperKnobs(options) {
const channel = addons.getChannel();
manager.setChannel(channel);

if (options) channel.emit('addon:knobs:setOptions', options);

switch (window.STORYBOOK_ENV) {
Expand Down