I am trying to display new page and start navigating automatically whenever user inputs both location in the input field. For that i am using useEffect method. But the object created is not working as expected and giving me error as
, or ) expected
ESLint: Parsing error: Unexpected token, expected ","
Expecting newline or semicolon
Can someone help me. As i am learning, i am new to all these. I have encountered almost same problem before. But i managed to fix it. It may be problem with the object. Anyone who can solve this, please explain it in detail. Code is as follow:
import React, {useEffect, useState} from 'react';
import {View, TextInput, SafeAreaView} from 'react-native';
import {GooglePlacesAutocomplete} from 'react-native-google-places-autocomplete';
import styles from './styles';
const DestinationSearch = props => {
const [originPlace, setOriginPlace] = useState({initalState: 'null'});
const [destinationPlace, setDestinationPlace] = useState({
initalState: 'null',
});
useEffect(effect:()=>{
if(originPlace && destinationPlace) {}
},deps[originPlace, destinationPlace])
return (
<SafeAreaView>
<View style={styles.container}>
<GooglePlacesAutocomplete
placeholder="From where?"
onPress={(
data: GooglePlaceData,
details: GooglePlaceDetail | null = null,
) => {
setDestinationPlace({value: {data, details}});
console.log(data, details);
}}
styles={{
textInput: styles.textInput,
}}
fetchDetails
query={{
key: 'AIzaSyB3rsn2ecpXZ8p9d8J_kLIH59rxt9KV6Rs',
language: 'en',
}}
/>
<GooglePlacesAutocomplete
placeholder="Where to?"
onPress={(
data: GooglePlaceData,
details: GooglePlaceDetail | null = null,
) => {
setDestinationPlace({value: {data, details}});
console.log(data, details);
}}
styles={{
textInput: styles.textInput,
}}
fetchDetails
query={{
key: 'AIzaSyB3rsn2ecpXZ8p9d8J_kLIH59rxt9KV6Rs',
language: 'en',
}}
/>
</View>
</SafeAreaView>
);
};
export default DestinationSearch;