Skip to content

Commit 8c26b3a

Browse files
committed
example: remove __assign wrapping
1 parent 76325bd commit 8c26b3a

File tree

3 files changed

+37
-51
lines changed

3 files changed

+37
-51
lines changed

packages/react-scripts/template/src/CounterClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export default class Counter extends Component {
2929
}
3030
}
3131

32-
HFF = window.__assign(module, 'HFF', HOCFunction(CounterFunction));
32+
HFF = HOCFunction(CounterFunction);
3333
module.hot.accept(['./CounterFunction', './HOCFunction'], window.__invalidate);

packages/react-scripts/template/src/CounterFunction.js

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,35 @@ let HFF;
55
let Counter;
66
let Fwd;
77

8-
Counter = window.__assign(
9-
module,
10-
'Counter',
11-
memo(
12-
memo(function Counter(props) {
13-
const [value, dispatch] = useReducer((v, a) => {
14-
return a === 'inc' ? v + 1 : v;
15-
}, 0);
16-
useLayoutEffect(() => {
17-
const id = setInterval(() => dispatch('inc'), 1000);
18-
return () => clearInterval(id);
19-
}, []);
8+
Counter = memo(
9+
memo(function Counter(props) {
10+
const [value, dispatch] = useReducer((v, a) => {
11+
return a === 'inc' ? v + 1 : v;
12+
}, 0);
13+
useLayoutEffect(() => {
14+
const id = setInterval(() => dispatch('inc'), 1000);
15+
return () => clearInterval(id);
16+
}, []);
2017

21-
return (
22-
<span>
23-
{value}
24-
{props.hocChild && (
25-
<>
26-
(inner HOC: <HFF /> {HFF.field})
27-
</>
28-
)}
29-
</span>
30-
);
31-
})
32-
)
18+
return (
19+
<span>
20+
{value}
21+
{props.hocChild && (
22+
<>
23+
(inner HOC: <HFF /> {HFF.field})
24+
</>
25+
)}
26+
</span>
27+
);
28+
})
3329
);
34-
Fwd = window.__assign(
35-
module,
36-
'FWD',
37-
forwardRef((props, ref) => (
38-
<span ref={ref}>
39-
<Counter {...props} />
40-
</span>
41-
))
42-
);
43-
HFF = window.__assign(module, 'HFF', HOCFunction(Fwd));
30+
31+
Fwd = forwardRef((props, ref) => (
32+
<span ref={ref}>
33+
<Counter {...props} />
34+
</span>
35+
));
36+
HFF = HOCFunction(Fwd);
4437

4538
module.hot.accept(['./HOCFunction'], window.__invalidate);
4639

packages/react-scripts/template/src/Hello.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,15 @@ export default function Hello() {
3636
);
3737
}
3838

39-
LazyCC = window.__assign(
40-
module,
41-
'LazyCC',
42-
lazy(() => import('./CounterClass'))
43-
);
44-
LazyCF = window.__assign(
45-
module,
46-
'LazyCF',
47-
lazy(() => import('./CounterFunction'))
48-
);
49-
DblCC = window.__assign(module, 'DblCC', CounterClass);
50-
DblCF = window.__assign(module, 'DblCF', CounterFunction);
51-
HCC = window.__assign(module, 'HCC', HOCClass(CounterClass, 'red'));
52-
HCF = window.__assign(module, 'HCF', HOCClass(CounterFunction, 'orange'));
53-
HFC = window.__assign(module, 'HFC', HOCFunction(CounterClass, 'yellow'));
54-
HFF = window.__assign(module, 'HFF', HOCFunction(CounterFunction, 'green'));
39+
LazyCC = lazy(() => import('./CounterClass'));
40+
LazyCF = lazy(() => import('./CounterFunction'));
41+
42+
DblCC = CounterClass;
43+
DblCF = CounterFunction;
44+
HCC = HOCClass(CounterClass, 'red');
45+
HCF = HOCClass(CounterFunction, 'orange');
46+
HFC = HOCFunction(CounterClass, 'yellow');
47+
HFF = HOCFunction(CounterFunction, 'green');
5548
module.hot.accept(
5649
['./CounterFunction', './CounterClass', './HOCFunction', './HOCClass'],
5750
window.__invalidate

0 commit comments

Comments
 (0)