Skip to content

Show migration warning only on mount #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/textField/TextFieldMigrator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {forwardRef} from 'react';
import React, {useEffect, forwardRef} from 'react';
import {mapKeys} from 'lodash';
// @ts-ignore
import OldTextField from './index';
Expand Down Expand Up @@ -53,12 +53,17 @@ function migrateProps(props: any) {
}

const TextFieldMigrator = forwardRef(({migrate = false, ...props}: any, ref) => {
useEffect(() => {
if (!migrate) {
LogService.warn(`RNUILib TextField component will soon be replaced with a new implementation, in order to start the migration - please pass the 'migrate' prop`);
}
}, []);

if (migrate) {
const migratedProps = migrateProps(props);
// @ts-ignore
return <NewTextField {...migratedProps} ref={ref}/>;
} else {
LogService.warn(`RNUILib TextField component will soon be replaced with a new implementation, in order to start the migration - please pass the 'migrate' prop`);
return <OldTextField {...props} ref={ref}/>;
}
});
Expand Down