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-contexts: Remove peer dependencies #7675

Merged
merged 7 commits into from
Sep 22, 2019
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
10 changes: 6 additions & 4 deletions addons/contexts/src/manager/ContextsManager.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import React, { useEffect, useState, useCallback } from 'react';
import { useChannel } from './libs/useChannel';
import { useChannel } from '@storybook/api';
import { ToolBar } from './components/ToolBar';
import { deserialize, serialize } from '../shared/serializers';
import { PARAM, REBOOT_MANAGER, UPDATE_MANAGER, UPDATE_PREVIEW } from '../shared/constants';
Expand All @@ -22,11 +22,13 @@ export const ContextsManager: ContextsManager = ({ api }) => {
);

// from preview
useChannel(UPDATE_MANAGER, newNodes => setNodes(newNodes || []), []);
const emit = useChannel({
[UPDATE_MANAGER]: newNodes => setNodes(newNodes || []),
});
leoyli marked this conversation as resolved.
Show resolved Hide resolved

// to preview
useEffect(() => api.emit(REBOOT_MANAGER), []);
useEffect(() => api.emit(UPDATE_PREVIEW, state), [state]);
useEffect(() => emit(REBOOT_MANAGER), []);
useEffect(() => emit(UPDATE_PREVIEW, state), [state]);
useEffect(() => api.setQueryParams({ [PARAM]: serialize(state) }), [state]);

return <ToolBar nodes={nodes} state={state || {}} setSelected={setSelected} />;
Expand Down
19 changes: 0 additions & 19 deletions addons/contexts/src/manager/libs/useChannel.ts

This file was deleted.