Skip to content

Commit 1719431

Browse files
committed
Render warning: fix for ReactComponentOfState
1 parent fb1ba3f commit 1719431

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/lib/react/ReactDebugMacro.hx

+15-9
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,21 @@ class ReactDebugMacro
156156

157157
if (cond)
158158
{
159-
// Using Object.create(null) to avoid prototype for clean output
160-
var debugProps = untyped Object.create(null);
161-
debugProps.currentProps = this.props;
162-
debugProps.prevProps = $i{prevProps};
163-
164-
js.Browser.console.warn(
165-
'Warning: avoidable re-render of `${$v{inClass.name}}`.\n',
166-
debugProps
167-
);
159+
${hasProps ? macro {
160+
// Using Object.create(null) to avoid prototype for clean output
161+
var debugProps = untyped Object.create(null);
162+
debugProps.currentProps = this.props;
163+
debugProps.prevProps = $i{prevProps};
164+
165+
js.Browser.console.warn(
166+
'Warning: avoidable re-render of `${$v{inClass.name}}`.\n',
167+
debugProps
168+
);
169+
} : macro {
170+
js.Browser.console.warn(
171+
'Warning: avoidable re-render of `${$v{inClass.name}}`.'
172+
);
173+
}};
168174

169175
if (react.ReactDebugMacro.firstRenderWarning)
170176
{

0 commit comments

Comments
 (0)