Skip to content

Commit

Permalink
add useCallback, minor style
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkiWines committed Apr 17, 2023
1 parent 88aa2ae commit 19dd2a7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pages/settings/Payments/AddPayPalMePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, {useRef, useState} from 'react';
import React, {
useRef, useState, useCallback,
} from 'react';
import {
View, TouchableWithoutFeedback, Linking,
} from 'react-native';
Expand Down Expand Up @@ -30,7 +32,7 @@ const AddPayPalMePage = (props) => {
/**
* Sets the payPalMe username and error data for the current user
*/
const setPayPalMeData = () => {
const setPayPalMeData = useCallback(() => {
if (!ValidationUtils.isValidPaypalUsername(payPalMeUsername)) {
setPayPalMeUsernameError(true);
return;
Expand All @@ -40,7 +42,7 @@ const AddPayPalMePage = (props) => {

Growl.show(props.translate('addPayPalMePage.growlMessageOnSave'), CONST.GROWL.SUCCESS, 3000);
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS);
};
}, [payPalMeUsername]);

return (
<ScreenWrapper onEntryTransitionEnd={() => payPalMeInput.current && payPalMeInput.current.focus()}>
Expand All @@ -62,7 +64,10 @@ const AddPayPalMePage = (props) => {
autoCorrect={false}
value={payPalMeUsername}
placeholder={props.translate('addPayPalMePage.yourPayPalUsername')}
onChangeText={(text) => { setPayPalMeUsername(text); setPayPalMeUsernameError(false); }}
onChangeText={(text) => {
setPayPalMeUsername(text);
setPayPalMeUsernameError(false);
}}
returnKeyType="done"
hasError={payPalMeUsernameError}
errorText={payPalMeUsernameError ? props.translate('addPayPalMePage.formatError') : ''}
Expand Down

0 comments on commit 19dd2a7

Please sign in to comment.