Skip to content

Commit

Permalink
refactor: Simplify component callback invocations
Browse files Browse the repository at this point in the history
The wrapping anonymous function is unnecessary now that the callback are
simply setting a single state value. Also, passing anonymous functions
to child components can lead to unnecessary re-renders.
  • Loading branch information
dcalhoun committed Aug 1, 2023
1 parent a0920c0 commit c438b77
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/components/src/mobile/link-picker/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ export const LinkPicker = ( {

useEffect( () => {
getURLFromClipboard()
.then( ( url ) => {
setClipboardUrl( url );
} )
.then( setClipboardUrl )
.catch( () => setClipboardUrl( '' ) );
}, [] );

Expand All @@ -113,9 +111,7 @@ export const LinkPicker = ( {
autoCapitalize="none"
autoCorrect={ false }
keyboardType="url"
onChangeValue={ ( newValue ) => {
setValue( newValue );
} }
onChangeValue={ setValue }
onSubmit={ onSubmit }
/* eslint-disable-next-line jsx-a11y/no-autofocus */
autoFocus
Expand Down

0 comments on commit c438b77

Please sign in to comment.