jaing / react-native-places-input

MIT License
46 stars 18 forks source link

Set default value #22

Closed tylerthedeveloper closed 4 years ago

tylerthedeveloper commented 4 years ago

is this possible?

i'd like have a default address selected

bhavya95 commented 4 years ago

@tylerthedeveloper you can use textInputProps textInputProps={{value: 'default value'}}

tylerthedeveloper commented 4 years ago

@bhavya95 then once you try to change it immediately resets itself because the value is bound to that ...

jaing commented 4 years ago

Can you provide more clarification?

tylerthedeveloper commented 4 years ago
tylerthedeveloper commented 4 years ago

All I have is

const [location, setLocation] = useState();

<PlaceInput ... onSelect={place => setLocation(place))} textInputProps={{ autoCorrect: false, value: location || "El Paso, Texas" }} .. />

ezgif com-video-to-gif

tylerthedeveloper commented 4 years ago

any thoughts @jaing ?

jaing commented 4 years ago

can you try with a query prop?

query: this.props.query || '',

tylerthedeveloper commented 4 years ago

so that worked when hardcoded, but I fetch current location (standard) and set it to that, and it never re-renders, even though console.log(currentLocation) will show the correct output

jaing commented 4 years ago

Please try 1.1.5. Component now will update a query value on prop change and there is a new config to clear query on palce select