-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathindex.ts
49 lines (48 loc) · 1.21 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
import { ComponentConfig, registerComponent } from "../config";
import { Fiber } from "react-reconciler";
import { RNButton, ButtonProps } from "./RNButton";
import { AppContainer } from "../../reconciler";
class ButtonConfig extends ComponentConfig {
tagName = RNButton.tagName;
shouldSetTextContent(nextProps: ButtonProps): boolean {
return true;
}
createInstance(
newProps: ButtonProps,
rootInstance: AppContainer,
context: any,
workInProgress: Fiber
): RNButton {
const widget = new RNButton();
widget.setProps(newProps, {});
return widget;
}
commitMount(
instance: RNButton,
newProps: ButtonProps,
internalInstanceHandle: any
): void {
if (newProps.visible !== false) {
instance.show();
}
return;
}
finalizeInitialChildren(
instance: RNButton,
newProps: ButtonProps,
rootContainerInstance: AppContainer,
context: any
): boolean {
return true;
}
commitUpdate(
instance: RNButton,
updatePayload: any,
oldProps: ButtonProps,
newProps: ButtonProps,
finishedWork: Fiber
): void {
instance.setProps(newProps, oldProps);
}
}
export const Button = registerComponent<ButtonProps>(new ButtonConfig());