@@ -4,21 +4,46 @@ function warn(message: string) {
4
4
}
5
5
}
6
6
7
- function deprecationWarn ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
7
+ function error ( message : string ) {
8
+ if ( __DEV__ ) {
9
+ console . error ( message ) ;
10
+ }
11
+ }
12
+
13
+ function getDeprecationMessage ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
8
14
const message = newProp
9
15
? `RNUILib's ${ component } "${ oldProp } " prop will be deprecated soon, please use the "${ newProp } " prop instead`
10
16
: `RNUILib's ${ component } "${ oldProp } " prop will be deprecated soon, please stop using it` ;
11
- warn ( message ) ;
17
+ return message ;
12
18
}
13
19
14
- function componentDeprecationWarn ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
20
+ function getComponentDeprecationMessage ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
15
21
const message = `RNUILib's ${ oldComponent } component will be deprecated soon, please use the "${ newComponent } " component instead` ;
16
22
17
- warn ( message ) ;
23
+ return message ;
24
+ }
25
+
26
+ function deprecationWarn ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
27
+ warn ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
28
+ }
29
+
30
+ function componentDeprecationWarn ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
31
+ warn ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
32
+ }
33
+
34
+ function deprecationError ( { component, oldProp, newProp} : { component : string ; oldProp : string ; newProp ?: string } ) {
35
+ error ( getDeprecationMessage ( { component, oldProp, newProp} ) ) ;
36
+ }
37
+
38
+ function componentDeprecationError ( { oldComponent, newComponent} : { oldComponent : string ; newComponent : string } ) {
39
+ error ( getComponentDeprecationMessage ( { oldComponent, newComponent} ) ) ;
18
40
}
19
41
20
42
export default {
21
43
warn,
44
+ error,
22
45
deprecationWarn,
23
- componentDeprecationWarn
46
+ componentDeprecationWarn,
47
+ deprecationError,
48
+ componentDeprecationError
24
49
} ;
0 commit comments