react-places-autocomplete icon indicating copy to clipboard operation
react-places-autocomplete copied to clipboard

How to apply localization to children?

Open nvtin opened this issue 5 years ago • 0 comments
trafficstars

{({ getInputProps, suggestions, getSuggestionItemProps, loading }) => (
          <div>
            <input
              {...getInputProps({
                placeholder: 'Search Places ...',
                className: 'location-search-input',
              })}
            />

As above children, I want to translate place holder based on current language. I am using const { t: translate } = useTranslation(); How can I use translate('inputPlaceholder') instead of 'Search Places ...'

{({ getInputProps, suggestions, getSuggestionItemProps, loading }) => (
          <div>
            <input
              {...getInputProps({
                placeholder: translate('inputPlaceholder'),
                className: 'location-search-input',
              })}
            />

Error I got: Uncaught TypeError: translate is not a function Because translate is not available in children scope. Any help? Thanks.

nvtin avatar Nov 18 '20 09:11 nvtin