Skip to content

Commit d995531

Browse files
authored
Show migration warning only on mount (#1162)
1 parent 8bcc21e commit d995531

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/textField/TextFieldMigrator.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {forwardRef} from 'react';
1+
import React, {useEffect, forwardRef} from 'react';
22
import {mapKeys} from 'lodash';
33
// @ts-ignore
44
import OldTextField from './index';
@@ -53,12 +53,17 @@ function migrateProps(props: any) {
5353
}
5454

5555
const TextFieldMigrator = forwardRef(({migrate = false, ...props}: any, ref) => {
56+
useEffect(() => {
57+
if (!migrate) {
58+
LogService.warn(`RNUILib TextField component will soon be replaced with a new implementation, in order to start the migration - please pass the 'migrate' prop`);
59+
}
60+
}, []);
61+
5662
if (migrate) {
5763
const migratedProps = migrateProps(props);
5864
// @ts-ignore
5965
return <NewTextField {...migratedProps} ref={ref}/>;
6066
} else {
61-
LogService.warn(`RNUILib TextField component will soon be replaced with a new implementation, in order to start the migration - please pass the 'migrate' prop`);
6267
return <OldTextField {...props} ref={ref}/>;
6368
}
6469
});

0 commit comments

Comments
 (0)