Skip to content

Commit f570e93

Browse files
committed
More stuff to think about
1 parent 25c69dc commit f570e93

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

Diff for: packages/react-scripts/template/src/CounterFunction.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Counter.__setImpl(function CounterImpl(props) {
1818
{value}
1919
{props.hocChild && (
2020
<>
21-
(inner HOC: <HFF />)
21+
(inner HOC: <HFF /> {HFF.field})
2222
</>
2323
)}
2424
</span>

Diff for: packages/react-scripts/template/src/HOCClass.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import React, { Component } from 'react';
22

3-
export default function withStuff(Wrapped) {
3+
export default function withStuff(Wrapped, color) {
44
return class extends Component {
5+
static field = 42;
56
render() {
6-
return <Wrapped {...this.props} />;
7+
return (
8+
<span style={{ color }}>
9+
<Wrapped {...this.props} />
10+
</span>
11+
);
712
}
813
};
914
}

Diff for: packages/react-scripts/template/src/HOCFunction.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React from 'react';
22

3-
export default function withStuff(Wrapped) {
4-
return function(props) {
5-
return <Wrapped {...props} />;
6-
};
3+
export default function withStuff(Wrapped, color) {
4+
function Wrapper(props) {
5+
return (
6+
<span style={{ color }}>
7+
<Wrapped {...props} />
8+
</span>
9+
);
10+
}
11+
Wrapper.field = 42;
12+
return Wrapper;
713
}

Diff for: packages/react-scripts/template/src/Hello.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ let HCF = window.__createProxy(module, 'HCF');
1010
let HFC = window.__createProxy(module, 'HFC');
1111
let HFF = window.__createProxy(module, 'HFF');
1212

13-
HCC.__setImpl(HOCClass(CounterClass));
14-
HCF.__setImpl(HOCClass(CounterFunction));
15-
HFC.__setImpl(HOCFunction(CounterClass));
16-
HFF.__setImpl(HOCFunction(CounterFunction));
13+
HCC.__setImpl(HOCClass(CounterClass, 'red'));
14+
HCF.__setImpl(HOCClass(CounterFunction, 'orange'));
15+
HFC.__setImpl(HOCFunction(CounterClass, 'yellow'));
16+
HFF.__setImpl(HOCFunction(CounterFunction, 'green'));
1717
Hello.__setImpl(function HelloImpl() {
1818
const [value] = useState(Math.random());
1919

2020
return (
2121
<h3>
2222
{value.toString().slice(0, 5)}
2323
<br />
24-
hello world!!!
24+
hello world!
2525
<br />
2626
class: <CounterClass hocChild />
2727
<br />

Diff for: packages/react-scripts/template/src/TODO.md

+25
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,28 @@
2121
- directives?
2222
- when to accept?
2323
- test integrations
24+
25+
lazy()?
26+
27+
- maybe Proxy?
28+
- do I want to preserve type? elementType? or what?
29+
or lazy element?
30+
31+
- what about static fields
32+
33+
- we either break Foo.thing or <Foo />.type?
34+
- maybe we never wrap, but point to latest from current one?
35+
- could also bail out
36+
37+
- how to force update all (incl. inside memo)
38+
39+
let A = createA();
40+
B() {
41+
<A />
42+
}
43+
44+
- two kinds of edits
45+
- reeval child with new data
46+
- remember new self
47+
48+
* think in terms of "assign"?

0 commit comments

Comments
 (0)