Skip to content

Commit 0f74265

Browse files
authored
Merge pull request #47 from mattdamon108/jsx-ppx-error-boundary
Use @react.component for ErrorBoundary
2 parents ef32529 + 8704f78 commit 0f74265

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Changes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## master
44

5-
- Nothing yet
5+
- Rewrite the `RescriptReactErrorBoundary` component implementation with `@react.component`, so it can be compatible with the changes of JSX PPX.
66

77
## v0.10.3
88

@@ -26,12 +26,14 @@ For history on previous evolution of the code, check out the original [reason-re
2626
- **IMPORTANT:** Currently, old third-party packages that are still dependent on `reason-react` will not mix with other `@rescript/react` based code due to a build system problem. Which means that every third-party dependency needs to be upgraded to `@rescript/react` first to make it compatible. See [this forum discussion](https://forum.rescript-lang.org/t/discussion-reason-react-rescript-react-migration-path/1086) for more details.
2727

2828
- Removed legacy modules ("record api"):
29+
2930
- `ReasonReactCompat`
3031
- `ReactDOMServerRe`
3132
- `ReactEventRe`
3233
- `ReasonReactOptimizedCreateClass`
3334

3435
- Renamed existing modules:
36+
3537
- `ReasonReactErrorBoundary` -> `RescriptReactErrorBoundary`
3638
- `ReasonReactRouter` -> `RescriptReactRouter`
3739
- (Note: Usually the two only valid styles would be `ReScript` or `rescript`, the latter being the version for technical writing. We are using `Rescript` here, since it is essentially the capitalized version of `rescript`)

src/RescriptReactErrorBoundary.res

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type params<'error> = {
1414
info: info,
1515
}
1616

17-
let getErrorBoundary = %raw(`
17+
let getErrorBoundary: reactComponentClass => React.element = %raw(`
1818
function (Component) {
1919
function ErrorBoundary(props) {
2020
Component.call(this);
@@ -31,12 +31,6 @@ let getErrorBoundary = %raw(`
3131
}
3232
`)
3333

34-
@obj
35-
external makeProps: (
36-
~children: React.element,
37-
~fallback: params<'error> => React.element,
38-
~key: string=?,
39-
unit,
40-
) => {"children": React.element, "fallback": params<'error> => React.element} = ""
41-
42-
let make = getErrorBoundary(component)
34+
@react.component
35+
let make = (~children as _: React.element, ~fallback as _: params<'error> => React.element) =>
36+
getErrorBoundary(component)

0 commit comments

Comments
 (0)