-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(shipping): CHECKOUT-4272 Stop passing arrow functions into compo…
…nents in shipping components
- Loading branch information
Showing
9 changed files
with
137 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { FieldProps } from 'formik'; | ||
import React, { useCallback, useMemo, FunctionComponent } from 'react'; | ||
|
||
import { TranslatedString } from '../locale'; | ||
import { Fieldset, FormField, Label, Legend, TextInput } from '../ui/form'; | ||
|
||
const OrderComments: FunctionComponent = () => ( | ||
<Fieldset testId="checkout-shipping-comments" | ||
legend={ | ||
<Legend> | ||
<TranslatedString id="shipping.order_comment_label" /> | ||
</Legend> | ||
} | ||
> | ||
const OrderComments: FunctionComponent = () => { | ||
const renderLabel = useCallback(name => ( | ||
<Label hidden htmlFor={ name }> | ||
<TranslatedString id="shipping.order_comment_label" /> | ||
</Label> | ||
), []); | ||
|
||
const renderInput = useCallback(({ field }: FieldProps) => ( | ||
<TextInput | ||
{ ...field } | ||
maxLength={ 2000 } | ||
autoComplete={ 'off' } | ||
/> | ||
), []); | ||
|
||
const legend = useMemo(() => ( | ||
<Legend> | ||
<TranslatedString id="shipping.order_comment_label" /> | ||
</Legend> | ||
), []); | ||
|
||
return <Fieldset testId="checkout-shipping-comments" legend={ legend }> | ||
<FormField | ||
name="orderComment" | ||
label={ name => ( | ||
<Label hidden htmlFor={ name }> | ||
<TranslatedString id="shipping.order_comment_label" /> | ||
</Label> | ||
) } | ||
input={ ({ field }) => ( | ||
<TextInput | ||
{ ...field } | ||
maxLength={ 2000 } | ||
autoComplete={'off'} | ||
/> | ||
)} | ||
label={ renderLabel } | ||
input={ renderInput } | ||
/> | ||
</Fieldset> | ||
); | ||
</Fieldset>; | ||
}; | ||
|
||
export default OrderComments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.