1 | import { useObserver } from "./useObserver";
|
2 | function ObserverComponent(_a) {
|
3 | var children = _a.children, render = _a.render;
|
4 | var component = children || render;
|
5 | if (typeof component !== "function") {
|
6 | return null;
|
7 | }
|
8 | return useObserver(component);
|
9 | }
|
10 | if ("production" !== process.env.NODE_ENV) {
|
11 | ObserverComponent.propTypes = {
|
12 | children: ObserverPropsCheck,
|
13 | render: ObserverPropsCheck
|
14 | };
|
15 | }
|
16 | ObserverComponent.displayName = "Observer";
|
17 | export { ObserverComponent as Observer };
|
18 | function ObserverPropsCheck(props, key, componentName, location, propFullName) {
|
19 | var extraKey = key === "children" ? "render" : "children";
|
20 | var hasProp = typeof props[key] === "function";
|
21 | var hasExtraProp = typeof props[extraKey] === "function";
|
22 | if (hasProp && hasExtraProp) {
|
23 | return new Error("MobX Observer: Do not use children and render in the same time in`" + componentName);
|
24 | }
|
25 | if (hasProp || hasExtraProp) {
|
26 | return null;
|
27 | }
|
28 | return new Error("Invalid prop `" +
|
29 | propFullName +
|
30 | "` of type `" +
|
31 | typeof props[key] +
|
32 | "` supplied to" +
|
33 | " `" +
|
34 | componentName +
|
35 | "`, expected `function`.");
|
36 | }
|
37 |
|
\ | No newline at end of file |