Skip to content

Commit c68d6b6

Browse files
committed
Revert "Handle parameters change"
This reverts commit 91ad09d.
1 parent 91ad09d commit c68d6b6

File tree

6 files changed

+17
-53
lines changed

6 files changed

+17
-53
lines changed

.storybook/stories.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ storiesOf('Storybook Addon Development Kit', module)
2121
.add(
2222
'Stories',
2323
() => {
24+
console.log('Render Button 1');
2425
return (
2526
<div>
2627
<button>Button 1</button>
2728
</div>
2829
);
2930
},
30-
adkParams({ currentTheme: 33 })
31+
adkParams({ currentTheme: 1 })
3132
)
3233
.add(
3334
'Stories2',

dev/withAdk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ const DecoratorUI = ({ context, getStory, theme, info }) => (
1313
export const withAdk = createDecorator({
1414
theme: store => store.themes[store.currentTheme],
1515
info: store => JSON.stringify(store, null, 2)
16-
})(DecoratorUI, { isGlobal: true, priorityOfparams: false });
16+
})(DecoratorUI, { isGlobal: true });
1717
export const adkParams = setParameters();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storybook/addon-devkit",
3-
"version": "1.2.1",
3+
"version": "1.2.0",
44
"description": "Storybook Addon Development Kit",
55
"author": {
66
"name": "Oleg Proskurin",

src/ChannelStore.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export default class ChannelStore {
6262
);
6363

6464
onInitChannel = initData => {
65-
console.log("TCL: ChannelStore -> onConnectedFn -> initData", initData)
6665
const { data, id } = initData;
6766
const selectorId = id || GLOBAL;
6867
const selectedData = { ...(this.store[selectorId] || {}) };

src/decorator.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ import withChannel from './withChannel';
33

44
import { getConfig } from './config';
55

6-
const DecoratorHOC = ({ actions, selectors, Component, parameters, resetParameters, ...props }) => {
7-
React.useEffect(() => {
8-
console.log('Effect:\n', parameters);
9-
resetParameters(parameters);
10-
}, [parameters, resetParameters]);
11-
return <Component {...actions} {...selectors} {...props} />
12-
};
6+
const DecoratorHOC = ({ actions, selectors, Component, ...props }) => (
7+
<Component {...actions} {...selectors} {...props} />
8+
);
139

1410
export const createDecorator = (storeSelectors, createActions) => (
1511
Component,
@@ -26,8 +22,6 @@ export const createDecorator = (storeSelectors, createActions) => (
2622
const parameters = context.parameters && context.parameters[PARAM_Key];
2723
const storyId = isGlobal ? null : context.id;
2824

29-
// const [prms, setParams] =
30-
3125
const WithChannel = withChannel({
3226
EVENT_ID_INIT,
3327
EVENT_ID_DATA,

src/withChannel.js

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const withChannel = ({
4141

4242
this.state = {
4343
data: initStateData,
44-
selectors: isReceived ? this.executeSelectors(initStateData) : {},
44+
selectors: isReceived ? this.prepareSelectors(initStateData) : {},
4545
isReceived,
4646
};
4747

@@ -60,7 +60,7 @@ const withChannel = ({
6060

6161
isPanel = this.props.panel || panel;
6262

63-
executeSelectors = store => {
63+
prepareSelectors = store => {
6464
return Object.entries(storeSelectors)
6565
.map(([name, selector]) => ({
6666
[name]: tryToSelect(selector)(store),
@@ -93,14 +93,14 @@ const withChannel = ({
9393

9494
componentWillUnmount() {
9595
this.debugLog('componentWillUnmount');
96-
this.store.disconnect();
97-
}
96+
this.store.disconnect();
97+
}
9898

99-
// debug = true;
100-
debug = false;
99+
// debug = true;
100+
debug = false;
101101

102-
debugLog = message => {
103-
if (!this.debug) {
102+
debugLog = message => {
103+
if (!this.debug) {
104104
return;
105105
}
106106
console.log(
@@ -114,45 +114,16 @@ const withChannel = ({
114114
this.setState({
115115
data,
116116
isReceived: true,
117-
selectors: this.executeSelectors(data),
117+
selectors: this.prepareSelectors(data),
118118
});
119119
};
120120

121-
resetParameters = parameters => {
122-
const initStateData = {
123-
...initData,
124-
...this.props.initData,
125-
...parameters,
126-
};
127-
this.setState({
128-
data: initStateData,
129-
selectors: this.state.isReceived ? this.executeSelectors(initStateData) : {},
130-
});
131-
this.store.sendInit(initStateData);
132-
}
133-
134121
render() {
135122
const { pointName, initData, active, onData, ...props } = this.props;
136-
const { data, isReceived } = this.state;
123+
const { data, isReceived, selectors } = this.state;
137124

138125
if (active === false) return null;
139126

140-
const initStateData = {
141-
...initData,
142-
...parameters,
143-
...data,
144-
};
145-
146-
let selectors;
147-
try {
148-
selectors = this.executeSelectors(initStateData)
149-
} catch (err) {
150-
selectors = this.state.selectors;
151-
}
152-
153-
console.log('Render', parameters);
154-
155-
156127
return (
157128
<WrappedComponent
158129
data={data}
@@ -163,7 +134,6 @@ const withChannel = ({
163134
selectors={selectors}
164135
actions={this.actions}
165136
isFirstDataReceived={isReceived}
166-
resetParameters={this.resetParameters}
167137
{...props}
168138
/>
169139
);

0 commit comments

Comments
 (0)