-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathindex.ts
50 lines (48 loc) · 1.24 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Fiber } from "react-reconciler";
import { registerComponent, ComponentConfig } from "../config";
import { RNCheckBox, CheckBoxProps } from "./RNCheckBox";
import { AppContainer } from "../../reconciler";
class CheckBoxConfig extends ComponentConfig {
tagName = RNCheckBox.tagName;
shouldSetTextContent(nextProps: CheckBoxProps): boolean {
return true;
}
createInstance(
newProps: CheckBoxProps,
rootInstance: AppContainer,
context: any,
workInProgress: Fiber
): RNCheckBox {
const widget = new RNCheckBox();
widget.setProps(newProps, {});
return widget;
}
finalizeInitialChildren(
instance: RNCheckBox,
newProps: CheckBoxProps,
rootContainerInstance: AppContainer,
context: any
): boolean {
return true;
}
commitMount(
instance: RNCheckBox,
newProps: CheckBoxProps,
internalInstanceHandle: any
): void {
if (newProps.visible !== false) {
instance.show();
}
return;
}
commitUpdate(
instance: RNCheckBox,
updatePayload: any,
oldProps: CheckBoxProps,
newProps: CheckBoxProps,
finishedWork: Fiber
): void {
instance.setProps(newProps, oldProps);
}
}
export const CheckBox = registerComponent<CheckBoxProps>(new CheckBoxConfig());