rescript-relay 3.5.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +14 -4
- package/package.json +12 -7
- package/ppx-linux +0 -0
- package/ppx-macos-arm64 +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/relay-compiler-win-x64/relay.exe +0 -0
- package/src/RescriptRelay.bs.js +151 -167
- package/src/RescriptRelay.res +61 -63
- package/src/RescriptRelay.resi +84 -110
- package/src/RescriptRelayUtils.bs.js +44 -47
- package/src/RescriptRelayUtils.res +3 -3
- package/src/RescriptRelay_Fragment.bs.js +56 -81
- package/src/RescriptRelay_Fragment.res +60 -52
- package/src/RescriptRelay_Fragment.resi +5 -5
- package/src/RescriptRelay_Internal.bs.js +38 -47
- package/src/RescriptRelay_Internal.res +5 -5
- package/src/RescriptRelay_Internal.resi +2 -4
- package/src/RescriptRelay_Mutation.bs.js +28 -42
- package/src/RescriptRelay_Mutation.res +4 -4
- package/src/RescriptRelay_Query.bs.js +43 -64
- package/src/RescriptRelay_Query.res +16 -13
- package/src/RescriptRelay_Query.resi +1 -1
- package/src/RescriptRelay_RelayResolvers.bs.js +2 -4
- package/src/RescriptRelay_Subscriptions.bs.js +9 -15
- package/src/RescriptRelay_Subscriptions.res +1 -1
- package/src/RescriptRelay_Subscriptions.resi +1 -1
- package/src/ReactDOMExperimental.bs.js +0 -23
- package/src/ReactDOMExperimental.res +0 -16
|
@@ -1,54 +1,40 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
let React = require("react");
|
|
5
|
+
let ReactRelay = require("react-relay");
|
|
6
|
+
let RelayRuntime = require("relay-runtime");
|
|
7
|
+
let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
|
|
8
8
|
|
|
9
9
|
function commitMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
updater: updater !== undefined ? (function (store, response) {
|
|
21
|
-
updater(store, convertResponse(response));
|
|
22
|
-
}) : undefined,
|
|
23
|
-
uploadables: uploadables
|
|
24
|
-
});
|
|
25
|
-
};
|
|
10
|
+
return (environment, variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables) => RelayRuntime.commitMutation(environment, {
|
|
11
|
+
mutation: node,
|
|
12
|
+
variables: convertVariables(variables),
|
|
13
|
+
onCompleted: onCompleted !== undefined ? (res, err) => onCompleted(convertResponse(res), (err == null) ? undefined : Primitive_option.some(err)) : undefined,
|
|
14
|
+
onError: onError,
|
|
15
|
+
optimisticResponse: optimisticResponse !== undefined ? Primitive_option.some(convertWrapRawResponse(Primitive_option.valFromOption(optimisticResponse))) : undefined,
|
|
16
|
+
optimisticUpdater: optimisticUpdater,
|
|
17
|
+
updater: updater !== undefined ? (store, response) => updater(store, convertResponse(response)) : undefined,
|
|
18
|
+
uploadables: uploadables
|
|
19
|
+
});
|
|
26
20
|
}
|
|
27
21
|
|
|
28
22
|
function useMutation(convertVariables, node, convertResponse, convertWrapRawResponse) {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
return () => {
|
|
24
|
+
let match = ReactRelay.useMutation(node);
|
|
25
|
+
let mutate = match[0];
|
|
32
26
|
return [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}) : undefined,
|
|
45
|
-
variables: convertVariables(variables),
|
|
46
|
-
uploadables: uploadables
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
}), [mutate]),
|
|
50
|
-
match[1]
|
|
51
|
-
];
|
|
27
|
+
React.useMemo(() => ((variables, optimisticUpdater, optimisticResponse, updater, onCompleted, onError, uploadables) => mutate({
|
|
28
|
+
onError: onError,
|
|
29
|
+
onCompleted: onCompleted !== undefined ? (res, err) => onCompleted(convertResponse(res), (err == null) ? undefined : Primitive_option.some(err)) : undefined,
|
|
30
|
+
optimisticResponse: optimisticResponse !== undefined ? Primitive_option.some(convertWrapRawResponse(Primitive_option.valFromOption(optimisticResponse))) : undefined,
|
|
31
|
+
optimisticUpdater: optimisticUpdater,
|
|
32
|
+
updater: updater !== undefined ? (store, response) => updater(store, convertResponse(response)) : undefined,
|
|
33
|
+
variables: convertVariables(variables),
|
|
34
|
+
uploadables: uploadables
|
|
35
|
+
})), [mutate]),
|
|
36
|
+
match[1]
|
|
37
|
+
];
|
|
52
38
|
};
|
|
53
39
|
}
|
|
54
40
|
|
|
@@ -16,7 +16,7 @@ type useMutationConfig<'response, 'rawResponse, 'variables> = {
|
|
|
16
16
|
type commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
|
|
17
17
|
mutation: mutationNode<'m>,
|
|
18
18
|
variables: 'variables,
|
|
19
|
-
onCompleted?: ('response,
|
|
19
|
+
onCompleted?: ('response, Nullable.t<array<mutationError>>) => unit,
|
|
20
20
|
onError?: mutationError => unit,
|
|
21
21
|
optimisticResponse?: 'rawResponse,
|
|
22
22
|
optimisticUpdater?: optimisticUpdaterFn,
|
|
@@ -26,7 +26,7 @@ type commitMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
|
|
|
26
26
|
|
|
27
27
|
type useMutationConfigRaw<'m, 'variables, 'response, 'rawResponse> = {
|
|
28
28
|
onError?: mutationError => unit,
|
|
29
|
-
onCompleted?: ('response,
|
|
29
|
+
onCompleted?: ('response, Nullable.t<array<mutationError>>) => unit,
|
|
30
30
|
onUnsubscribe?: unit => unit,
|
|
31
31
|
optimisticResponse?: 'rawResponse,
|
|
32
32
|
optimisticUpdater?: optimisticUpdaterFn,
|
|
@@ -76,7 +76,7 @@ let commitMutation = (
|
|
|
76
76
|
{
|
|
77
77
|
mutation: node,
|
|
78
78
|
onCompleted: ?switch onCompleted {
|
|
79
|
-
| Some(cb) => Some((res, err) => cb(res->convertResponse, err->
|
|
79
|
+
| Some(cb) => Some((res, err) => cb(res->convertResponse, err->Nullable.toOption))
|
|
80
80
|
| None => None
|
|
81
81
|
},
|
|
82
82
|
?onError,
|
|
@@ -122,7 +122,7 @@ let useMutation = (
|
|
|
122
122
|
) => {
|
|
123
123
|
mutate({
|
|
124
124
|
onCompleted: ?switch onCompleted {
|
|
125
|
-
| Some(cb) => Some((res, err) => cb(res->convertResponse, err->
|
|
125
|
+
| Some(cb) => Some((res, err) => cb(res->convertResponse, err->Nullable.toOption))
|
|
126
126
|
| None => None
|
|
127
127
|
},
|
|
128
128
|
?onError,
|
|
@@ -1,92 +1,71 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
4
|
+
let React = require("react");
|
|
5
|
+
let ReactRelay = require("react-relay");
|
|
6
|
+
let RelayRuntime = require("relay-runtime");
|
|
7
|
+
let Primitive_option = require("@rescript/runtime/lib/js/Primitive_option.js");
|
|
8
|
+
let RescriptRelay_Internal = require("./RescriptRelay_Internal.bs.js");
|
|
10
9
|
|
|
11
10
|
function useQuery(convertVariables, node, convertResponse) {
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
|
|
19
|
-
};
|
|
11
|
+
return (variables, fetchPolicy, fetchKey, networkCacheConfig) => RescriptRelay_Internal.internal_useConvertedValue(convertResponse, ReactRelay.useLazyLoadQuery(node, RescriptRelay_Internal.internal_cleanObjectFromUndefinedRaw(convertVariables(variables)), {
|
|
12
|
+
fetchKey: fetchKey,
|
|
13
|
+
fetchPolicy: fetchPolicy,
|
|
14
|
+
networkCacheConfig: networkCacheConfig
|
|
15
|
+
}));
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
function useLoader(convertVariables, node, mkQueryRef) {
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
networkCacheConfig: networkCacheConfig
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}), [loadQueryFn]);
|
|
19
|
+
return () => {
|
|
20
|
+
let match = ReactRelay.useQueryLoader(node);
|
|
21
|
+
let loadQueryFn = match[1];
|
|
22
|
+
let loadQuery = React.useMemo(() => ((variables, fetchPolicy, networkCacheConfig) => loadQueryFn(convertVariables(variables), {
|
|
23
|
+
fetchPolicy: fetchPolicy,
|
|
24
|
+
networkCacheConfig: networkCacheConfig
|
|
25
|
+
})), [loadQueryFn]);
|
|
34
26
|
return [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
mkQueryRef(Primitive_option.fromNullable(match[0])),
|
|
28
|
+
loadQuery,
|
|
29
|
+
match[2]
|
|
30
|
+
];
|
|
39
31
|
};
|
|
40
32
|
}
|
|
41
33
|
|
|
42
34
|
function usePreloaded(node, convertResponse, mkQueryRef) {
|
|
43
|
-
return
|
|
44
|
-
var __x = ReactRelay.usePreloadedQuery(node, mkQueryRef(queryRef));
|
|
45
|
-
return RescriptRelay_Internal.internal_useConvertedValue(convertResponse, __x);
|
|
46
|
-
};
|
|
35
|
+
return queryRef => RescriptRelay_Internal.internal_useConvertedValue(convertResponse, ReactRelay.usePreloadedQuery(node, mkQueryRef(queryRef)));
|
|
47
36
|
}
|
|
48
37
|
|
|
49
|
-
function
|
|
50
|
-
return
|
|
38
|
+
function fetch(node, convertResponse, convertVariables) {
|
|
39
|
+
return (environment, variables, onResult, networkCacheConfig, fetchPolicy) => {
|
|
51
40
|
ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
_0: err
|
|
65
|
-
});
|
|
66
|
-
})
|
|
67
|
-
});
|
|
41
|
+
networkCacheConfig: networkCacheConfig,
|
|
42
|
+
fetchPolicy: fetchPolicy
|
|
43
|
+
}).subscribe({
|
|
44
|
+
next: res => onResult({
|
|
45
|
+
TAG: "Ok",
|
|
46
|
+
_0: convertResponse(res)
|
|
47
|
+
}),
|
|
48
|
+
error: err => onResult({
|
|
49
|
+
TAG: "Error",
|
|
50
|
+
_0: err
|
|
51
|
+
})
|
|
52
|
+
});
|
|
68
53
|
};
|
|
69
54
|
}
|
|
70
55
|
|
|
71
56
|
function fetchPromised(node, convertResponse, convertVariables) {
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}).toPromise(), (function (res) {
|
|
77
|
-
return Promise.resolve(convertResponse(res));
|
|
78
|
-
}));
|
|
79
|
-
};
|
|
57
|
+
return (environment, variables, networkCacheConfig, fetchPolicy) => ReactRelay.fetchQuery(environment, node, convertVariables(variables), {
|
|
58
|
+
networkCacheConfig: networkCacheConfig,
|
|
59
|
+
fetchPolicy: fetchPolicy
|
|
60
|
+
}).toPromise().then(res => Promise.resolve(convertResponse(res)));
|
|
80
61
|
}
|
|
81
62
|
|
|
82
63
|
function retain(node, convertVariables) {
|
|
83
|
-
return
|
|
84
|
-
return environment.retain(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)));
|
|
85
|
-
};
|
|
64
|
+
return (environment, variables) => environment.retain(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)));
|
|
86
65
|
}
|
|
87
66
|
|
|
88
67
|
function commitLocalPayload(node, convertVariables, convertWrapRawResponse) {
|
|
89
|
-
return
|
|
68
|
+
return (environment, variables, payload) => {
|
|
90
69
|
environment.commitPayload(RelayRuntime.createOperationDescriptor(node, convertVariables(variables)), convertWrapRawResponse(payload));
|
|
91
70
|
};
|
|
92
71
|
}
|
|
@@ -94,7 +73,7 @@ function commitLocalPayload(node, convertVariables, convertWrapRawResponse) {
|
|
|
94
73
|
exports.useQuery = useQuery;
|
|
95
74
|
exports.useLoader = useLoader;
|
|
96
75
|
exports.usePreloaded = usePreloaded;
|
|
97
|
-
exports
|
|
76
|
+
exports.fetch = fetch;
|
|
98
77
|
exports.fetchPromised = fetchPromised;
|
|
99
78
|
exports.retain = retain;
|
|
100
79
|
exports.commitLocalPayload = commitLocalPayload;
|
|
@@ -31,7 +31,7 @@ let useQuery = (
|
|
|
31
31
|
?fetchPolicy,
|
|
32
32
|
?networkCacheConfig,
|
|
33
33
|
},
|
|
34
|
-
)->
|
|
34
|
+
)->RescriptRelay_Internal.internal_useConvertedValue(convertResponse, _)
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -42,7 +42,7 @@ type useQueryLoaderOptions = {
|
|
|
42
42
|
|
|
43
43
|
@module("react-relay")
|
|
44
44
|
external useQueryLoader: queryNode<'node> => (
|
|
45
|
-
|
|
45
|
+
Nullable.t<'queryRef>,
|
|
46
46
|
('variables, useQueryLoaderOptions) => unit,
|
|
47
47
|
unit => unit,
|
|
48
48
|
) = "useQueryLoader"
|
|
@@ -55,11 +55,12 @@ let useLoader = (
|
|
|
55
55
|
() => {
|
|
56
56
|
let (nullableQueryRef, loadQueryFn, disposableFn) = useQueryLoader(node)
|
|
57
57
|
let loadQuery = React.useMemo1(
|
|
58
|
-
() =>
|
|
59
|
-
|
|
58
|
+
() =>
|
|
59
|
+
(~variables, ~fetchPolicy=?, ~networkCacheConfig=?) =>
|
|
60
|
+
loadQueryFn(variables->convertVariables, {?fetchPolicy, ?networkCacheConfig}),
|
|
60
61
|
[loadQueryFn],
|
|
61
62
|
)
|
|
62
|
-
(nullableQueryRef->
|
|
63
|
+
(nullableQueryRef->Nullable.toOption->mkQueryRef, loadQuery, disposableFn)
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -70,14 +71,16 @@ let usePreloaded = (
|
|
|
70
71
|
~node,
|
|
71
72
|
~convertResponse: 'response => 'response,
|
|
72
73
|
~mkQueryRef: 'queryRef => 'queryRef,
|
|
73
|
-
) =>
|
|
74
|
+
) =>
|
|
75
|
+
/** Combine this with `Query.useLoader` or \
|
|
74
76
|
`YourQueryName_graphql.load()` to use a query you've started \
|
|
75
77
|
preloading before rendering. */
|
|
76
|
-
(~queryRef: 'queryRef) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
(~queryRef: 'queryRef) => {
|
|
79
|
+
usePreloadedQuery(
|
|
80
|
+
node,
|
|
81
|
+
queryRef->mkQueryRef,
|
|
82
|
+
)->RescriptRelay_Internal.internal_useConvertedValue(convertResponse, _)
|
|
83
|
+
}
|
|
81
84
|
|
|
82
85
|
@module("react-relay")
|
|
83
86
|
external fetchQuery: (
|
|
@@ -94,7 +97,7 @@ let fetch = (
|
|
|
94
97
|
) => {
|
|
95
98
|
/**\n\
|
|
96
99
|
This fetches the query in a one-off fashion, and returns a \
|
|
97
|
-
`
|
|
100
|
+
`result` in a callback for convenience. Use \
|
|
98
101
|
`Query.fetchPromised` if you need this but with promises.\n\n\
|
|
99
102
|
Please *avoid* using `Query.fetch` unless you really need it, \
|
|
100
103
|
since the data you fetch here isn't guaranteed to stick around \
|
|
@@ -139,7 +142,7 @@ let fetchPromised = (
|
|
|
139
142
|
Some({?networkCacheConfig, ?fetchPolicy}),
|
|
140
143
|
)
|
|
141
144
|
->Observable.toPromise
|
|
142
|
-
->
|
|
145
|
+
->Promise.then(res => res->convertResponse->Promise.resolve)
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
148
|
|
|
@@ -34,7 +34,7 @@ let fetch: (
|
|
|
34
34
|
) => (
|
|
35
35
|
~environment: Environment.t,
|
|
36
36
|
~variables: 'variables,
|
|
37
|
-
~onResult: result<'response,
|
|
37
|
+
~onResult: result<'response, JsExn.t> => unit,
|
|
38
38
|
~networkCacheConfig: cacheConfig=?,
|
|
39
39
|
~fetchPolicy: fetchPolicy=?,
|
|
40
40
|
) => unit
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let ResolverFragments = require("relay-runtime/lib/store/ResolverFragments");
|
|
5
5
|
|
|
6
6
|
function makeRelayResolver(node, convertFragment, resolver) {
|
|
7
|
-
return
|
|
8
|
-
return resolver(convertFragment(ResolverFragments.readFragment(node, fRef)));
|
|
9
|
-
};
|
|
7
|
+
return fRef => resolver(convertFragment(ResolverFragments.readFragment(node, fRef)));
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
exports.makeRelayResolver = makeRelayResolver;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
let RelayRuntime = require("relay-runtime");
|
|
5
5
|
|
|
6
6
|
function subscribe(node, convertVariables, convertResponse) {
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}) : undefined,
|
|
16
|
-
updater: updater !== undefined ? (function (store, response) {
|
|
17
|
-
updater(store, convertResponse(response));
|
|
18
|
-
}) : undefined
|
|
19
|
-
});
|
|
20
|
-
};
|
|
7
|
+
return (environment, variables, onCompleted, onError, onNext, updater) => RelayRuntime.requestSubscription(environment, {
|
|
8
|
+
subscription: node,
|
|
9
|
+
variables: convertVariables(variables),
|
|
10
|
+
onCompleted: onCompleted,
|
|
11
|
+
onError: onError,
|
|
12
|
+
onNext: onNext !== undefined ? response => onNext(convertResponse(response)) : undefined,
|
|
13
|
+
updater: updater !== undefined ? (store, response) => updater(store, convertResponse(response)) : undefined
|
|
14
|
+
});
|
|
21
15
|
}
|
|
22
16
|
|
|
23
17
|
exports.subscribe = subscribe;
|
|
@@ -5,7 +5,7 @@ type subscriptionConfig<'node, 'variables, 'response> = {
|
|
|
5
5
|
subscription: subscriptionNode<'node>,
|
|
6
6
|
variables: 'variables,
|
|
7
7
|
onCompleted?: unit => unit,
|
|
8
|
-
onError?:
|
|
8
|
+
onError?: JsExn.t => unit,
|
|
9
9
|
onNext?: 'response => unit,
|
|
10
10
|
updater?: updaterFn<'response>,
|
|
11
11
|
}
|
|
@@ -8,7 +8,7 @@ let subscribe: (
|
|
|
8
8
|
~environment: Environment.t,
|
|
9
9
|
~variables: 'variables,
|
|
10
10
|
~onCompleted: unit => unit=?,
|
|
11
|
-
~onError:
|
|
11
|
+
~onError: JsExn.t => unit=?,
|
|
12
12
|
~onNext: 'response => unit=?,
|
|
13
13
|
~updater: (RecordSourceSelectorProxy.t, 'response) => unit=?,
|
|
14
14
|
) => Disposable.t
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var ReactDOM = require("@rescript/react/src/ReactDOM.bs.js");
|
|
5
|
-
var Client = require("react-dom/client");
|
|
6
|
-
|
|
7
|
-
function renderConcurrentRootAtElementWithId(content, id) {
|
|
8
|
-
var element = document.getElementById(id);
|
|
9
|
-
if (element == null) {
|
|
10
|
-
throw {
|
|
11
|
-
RE_EXN_ID: "Invalid_argument",
|
|
12
|
-
_1: "ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " + id + " found in the HTML.",
|
|
13
|
-
Error: new Error()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
Client.createRoot(element).render(content);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var Root = ReactDOM.Client.Root;
|
|
20
|
-
|
|
21
|
-
exports.Root = Root;
|
|
22
|
-
exports.renderConcurrentRootAtElementWithId = renderConcurrentRootAtElementWithId;
|
|
23
|
-
/* react-dom/client Not a pure module */
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
include ReactDOM.Client
|
|
2
|
-
|
|
3
|
-
@val @return(nullable)
|
|
4
|
-
external getElementById: string => option<Dom.element> = "document.getElementById"
|
|
5
|
-
|
|
6
|
-
let renderConcurrentRootAtElementWithId: (React.element, string) => unit = (content, id) =>
|
|
7
|
-
switch getElementById(id) {
|
|
8
|
-
| None =>
|
|
9
|
-
raise(
|
|
10
|
-
Invalid_argument(
|
|
11
|
-
"ReactExperimental.renderConcurrentRootAtElementWithId : no element of id " ++
|
|
12
|
-
id ++ " found in the HTML.",
|
|
13
|
-
),
|
|
14
|
-
)
|
|
15
|
-
| Some(element) => createRoot(element)->Root.render(content)
|
|
16
|
-
}
|