Skip to content

Commit 7e8779e

Browse files
committed
remove hardcoded require
1 parent 15c7f0d commit 7e8779e

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/RescriptReactErrorBoundary.bs.js

+8-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RescriptReactErrorBoundary.res

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ type params<'error> = {
1010
info: info,
1111
}
1212

13+
type reactComponentClass
14+
@module("react") external component: reactComponentClass = "Component"
15+
let noOp: reactComponentClass => unit = %raw(`function (_x) {}`)
16+
let reactComponentClass = component
17+
// this is so that the compiler doesn't optimize away the previous line
18+
noOp(reactComponentClass)
19+
1320
%%raw(`
14-
var React = require("react");
1521
1622
var ErrorBoundary = (function (Component) {
1723
function ErrorBoundary(props) {
@@ -28,7 +34,7 @@ var ErrorBoundary = (function (Component) {
2834
: this.props.children;
2935
};
3036
return ErrorBoundary;
31-
})(React.Component);
37+
})(reactComponentClass);
3238
`)
3339

3440
@react.component @val

0 commit comments

Comments
 (0)