You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[`tink_hxx`](https://github.com/haxetink/tink_hxx) is used to handle jsx.
14
18
15
-
This implies some little syntax changes:
19
+
### Syntax changes
20
+
21
+
The change of parser implies some little syntax changes:
16
22
*`prop=$42` and such are no longer allowed, use `prop=${42}` or `prop={42}`
17
23
*`prop=${true}` can now be expressed as simply `prop`
18
24
25
+
### Misc changes
26
+
19
27
Other changes introduced by tink_hxx:
20
28
* Props are type-checked against the component's `TProps`
21
29
* You cannot pass props not recognized by the target component
30
+
*[Needs a tink_hxx release] You can use `${/* comments */}` / `{/* comments */}`in jsx
31
+
32
+
### Further changes added in `#next`
33
+
34
+
#### [`6e8fe8d`](https://github.com/kLabz/haxe-react/commit/6e8fe8d) Allow String variables as jsx node
35
+
36
+
The new parser will resolve `String` variables for node names:
37
+
38
+
```haxe
39
+
var Node = isTitle ? 'h2' : 'p';
40
+
return jsx('<$Node>${props.children}</$Node>');
41
+
```
42
+
43
+
**Warning**: it only works for variable names starting with an uppercase letter.
44
+
45
+
#### [`d173de0`](https://github.com/kLabz/haxe-react/commit/d173de0) Fix error position when using invalid nodes in jsx
46
+
47
+
Using an invalid node inside jsx, such as `<$UnknownComponent />`, resulted in
48
+
an error inside `haxe.macro.MacroStringTools`.
49
+
50
+
This fix ensures that the position points to "UnknownComponent" inside the jsx
51
+
string.
52
+
53
+
#### [`578c55d`](https://github.com/kLabz/haxe-react/commit/578c55d) Disallow invalid values inside jsx when a fragment is expected
54
+
55
+
For example, the following used to compile:
56
+
57
+
jsx('<div>${function() return 42}</div>');
58
+
59
+
But resulted in a runtime error:
60
+
61
+
Warning: Functions are not valid as a React child. This may happen if you
62
+
return a Component instead of <Component /> from render. Or maybe you meant
63
+
to call this function rather than return it.
64
+
65
+
Or, for objects: `jsx('<div>${{test: 42}}</div>');` resulted in:
66
+
67
+
Uncaught Error: Objects are not valid as a React child (found: object with
68
+
keys {test}). If you meant to render a collection of children,
69
+
use an array instead.
70
+
71
+
Now we get a compilation error (see below for `react.ReactFragment`):
72
+
73
+
src/Index.hx:31: characters 7-17 : { test : Int } should be react.ReactFragment
74
+
src/Index.hx:31: characters 7-17 : For function argument 'children'
75
+
76
+
#### [`425cb6c`](https://github.com/kLabz/haxe-react/commit/425cb6c) Ensure individual prop typing, allowing abstract props to do their magic
22
77
23
-
Further changes added in `#next`:
24
-
*[`6e8fe8d`](https://github.com/kLabz/haxe-react/commit/6e8fe8d) Allow String variables as jsx node
25
-
*[`d173de0`](https://github.com/kLabz/haxe-react/commit/d173de0) Fix error position when using invalid nodes in jsx
26
-
*[`578c55d`](https://github.com/kLabz/haxe-react/commit/578c55d) Disallow invalid values inside jsx when a fragment is expected
27
-
*[`425cb6c`](https://github.com/kLabz/haxe-react/commit/425cb6c) Ensure individual prop typing, allowing abstract props to do their magic
28
-
*[`150b76d`](https://github.com/kLabz/haxe-react/commit/150b76d) Jsx: display compilation warning on missing props
78
+
Makes sure each prop resolves to its type, with a `(prop :TypeOfProp)`.
79
+
80
+
This will trigger abstracts `@:from` / `@:to` which may be needed in some cases
0 commit comments