Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion src/lib/react/ReactMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ class ReactMacro
}

// Support "import as"
function deepFollow(t:Type) return TypeTools.map(Context.follow(t), deepFollow);
function deepFollow(t:Type) {
if (t == null) return null;
return TypeTools.map(Context.follow(t), deepFollow);
}

var t = deepFollow(Context.typeof(macro {
var __pseudo = $target;
Expand Down
13 changes: 13 additions & 0 deletions test/src/ReactMacroTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class CompBasic extends ReactComponent {}
@:ignoreEmptyRender
class CompBasicProps extends ReactComponentOfProps<{a:Int}> {}

@:ignoreEmptyRender
class CompRenderFunctionProps extends ReactComponentOfProps<{?render:()->ReactElement}> {}

typedef RenderProps = {
@:optional var children:Int->ReactFragment;
}
Expand Down Expand Up @@ -409,6 +412,16 @@ class ReactMacroTest
}
}

@Test
public function render_function_props() {
function fn() return jsx('<></>');
var e = jsx('<CompRenderFunctionProps render=${fn}/>');
assertHasProps(
e.props,
['render'], [fn]
);
}

@Test
public function DOM_with_children_should_be_array()
{
Expand Down