Skip to content

Commit

Permalink
remove hardcoded require
Browse files Browse the repository at this point in the history
  • Loading branch information
tsnobip committed Jun 7, 2024
1 parent 15c7f0d commit 7e8779e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/RescriptReactErrorBoundary.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/RescriptReactErrorBoundary.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ type params<'error> = {
info: info,
}

type reactComponentClass
@module("react") external component: reactComponentClass = "Component"
let noOp: reactComponentClass => unit = %raw(`function (_x) {}`)
let reactComponentClass = component
// this is so that the compiler doesn't optimize away the previous line
noOp(reactComponentClass)

%%raw(`
var React = require("react");
var ErrorBoundary = (function (Component) {
function ErrorBoundary(props) {
Expand All @@ -28,7 +34,7 @@ var ErrorBoundary = (function (Component) {
: this.props.children;
};
return ErrorBoundary;
})(React.Component);
})(reactComponentClass);
`)

@react.component @val
Expand Down

0 comments on commit 7e8779e

Please sign in to comment.