React Native Google place - getAutocompletePredictions is not returning the value fetched
I am using the react-native-google-places to fetch the results based on the user input.
I can able to console log the search result based on the autocomplete user input, but it's not returning the value in my custom listview.
Code
export function getAddressPredictions(){
return(dispatch, store)=>{
let userInput = store().home.resultTypes.pickUp ? store().home.inputData.pickUp : store().home.inputData.dropOff;
RNGooglePlaces.getAutocompletePredictions(userInput,
{
country:"IND"
}
)
.then((results)=>
dispatch({
type:GET_ADDRESS_PREDICTIONS,
payload:results
})
)
.catch((error)=> console.log(error.message));
};
}
function handleGetAddressPredictions(state, action){
return update(state, {
predictions:{
$set:action.payload
}
})
}
const ACTION_HANDLERS = {
GET_ADDRESS_PREDICTIONS:handleGetAddressPredictions
}
Here is the custom listview to show the search in the based on the user input.
export const SearchResults = (predictions)=>{
return (
<View style={styles.searchResultsWrapper} >
<List
dataArray={predictions}
renderRow={(item)=>
<View>
<ListItem button avatar>
<Left style={styles.leftContainer}>
<Icon style={styles.leftIcon} name="location-on" />
</Left>
<Body>
<Text style={styles.primaryText}>{item.primaryText}</Text>
<Text style={styles.secondaryText}>{item.secondaryText}</Text>
</Body>
</ListItem>
</View>
}
/>
</View>
);
}
export default SearchResults;
The above code properly fetching the details in the console log but i am unable to return the valus in the listview.
If i replace the {item.primaryText} with hardcorded text, its getting displayed.
Log File
{home: {…}}
home:
inputData: {pickUp: "drive"}
predictions: Array(5)
0: {types: Array(2), placeID: "EkBEcml2ZSBJbiBSb2FkLCBTdW5yaXNlIFBhcmssIE1lbW5hZ2…6z6yEXjkRMJeafp9UzlASFAoSCYfkscixhF45ESTcwBLlzE9c", secondaryText: "Sunrise Park, Memnagar, Ahmedabad, Gujarat, India", primaryText: "Drive In Road", fullText: "Drive In Road, Sunrise Park, Memnagar, Ahmedabad, Gujarat, India"}
1: {types: Array(4), placeID: "ChIJ4dTf1U1mUjoRSSPy-3Y49qk", secondaryText: "Chennai, Tamil Nadu, India", primaryText: "Drivers Colony, T Nagar", fullText: "Drivers Colony, T Nagar, Chennai, Tamil Nadu, India"}
2: {types: Array(4), placeID: "ChIJRWoDFq6EXjkRCmo7r2rn_xw", secondaryText: "Sunrise Park, Gurukul, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Sunrise Park, Gurukul, Ahmedabad, Gujarat"}
3: {types: Array(4), placeID: "ChIJlaOzFK6EXjkR86sdRNqJgqY", secondaryText: "Nilmani Society, Thaltej, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Nilmani Society, Thaltej, Ahmedabad, Gujarat"}
4: {types: Array(1), placeID: "ChIJiVzj_YiUyzsRHgB632DAI44", secondaryText: "Financial District, Gachibowli, Hyderabad, Telangana, India", primaryText: "Driven Cafe", fullText: "Driven Cafe, Financial District, Gachibowli, Hyderabad, Telangana, India"}
length: 5
__proto__: Array(0)
region: {}
resultTypes: {pickUp: true, dropOff: false}
Expected result - Places should be displayed in the listview.
google-maps react-native react-native-maps
add a comment |
I am using the react-native-google-places to fetch the results based on the user input.
I can able to console log the search result based on the autocomplete user input, but it's not returning the value in my custom listview.
Code
export function getAddressPredictions(){
return(dispatch, store)=>{
let userInput = store().home.resultTypes.pickUp ? store().home.inputData.pickUp : store().home.inputData.dropOff;
RNGooglePlaces.getAutocompletePredictions(userInput,
{
country:"IND"
}
)
.then((results)=>
dispatch({
type:GET_ADDRESS_PREDICTIONS,
payload:results
})
)
.catch((error)=> console.log(error.message));
};
}
function handleGetAddressPredictions(state, action){
return update(state, {
predictions:{
$set:action.payload
}
})
}
const ACTION_HANDLERS = {
GET_ADDRESS_PREDICTIONS:handleGetAddressPredictions
}
Here is the custom listview to show the search in the based on the user input.
export const SearchResults = (predictions)=>{
return (
<View style={styles.searchResultsWrapper} >
<List
dataArray={predictions}
renderRow={(item)=>
<View>
<ListItem button avatar>
<Left style={styles.leftContainer}>
<Icon style={styles.leftIcon} name="location-on" />
</Left>
<Body>
<Text style={styles.primaryText}>{item.primaryText}</Text>
<Text style={styles.secondaryText}>{item.secondaryText}</Text>
</Body>
</ListItem>
</View>
}
/>
</View>
);
}
export default SearchResults;
The above code properly fetching the details in the console log but i am unable to return the valus in the listview.
If i replace the {item.primaryText} with hardcorded text, its getting displayed.
Log File
{home: {…}}
home:
inputData: {pickUp: "drive"}
predictions: Array(5)
0: {types: Array(2), placeID: "EkBEcml2ZSBJbiBSb2FkLCBTdW5yaXNlIFBhcmssIE1lbW5hZ2…6z6yEXjkRMJeafp9UzlASFAoSCYfkscixhF45ESTcwBLlzE9c", secondaryText: "Sunrise Park, Memnagar, Ahmedabad, Gujarat, India", primaryText: "Drive In Road", fullText: "Drive In Road, Sunrise Park, Memnagar, Ahmedabad, Gujarat, India"}
1: {types: Array(4), placeID: "ChIJ4dTf1U1mUjoRSSPy-3Y49qk", secondaryText: "Chennai, Tamil Nadu, India", primaryText: "Drivers Colony, T Nagar", fullText: "Drivers Colony, T Nagar, Chennai, Tamil Nadu, India"}
2: {types: Array(4), placeID: "ChIJRWoDFq6EXjkRCmo7r2rn_xw", secondaryText: "Sunrise Park, Gurukul, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Sunrise Park, Gurukul, Ahmedabad, Gujarat"}
3: {types: Array(4), placeID: "ChIJlaOzFK6EXjkR86sdRNqJgqY", secondaryText: "Nilmani Society, Thaltej, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Nilmani Society, Thaltej, Ahmedabad, Gujarat"}
4: {types: Array(1), placeID: "ChIJiVzj_YiUyzsRHgB632DAI44", secondaryText: "Financial District, Gachibowli, Hyderabad, Telangana, India", primaryText: "Driven Cafe", fullText: "Driven Cafe, Financial District, Gachibowli, Hyderabad, Telangana, India"}
length: 5
__proto__: Array(0)
region: {}
resultTypes: {pickUp: true, dropOff: false}
Expected result - Places should be displayed in the listview.
google-maps react-native react-native-maps
add a comment |
I am using the react-native-google-places to fetch the results based on the user input.
I can able to console log the search result based on the autocomplete user input, but it's not returning the value in my custom listview.
Code
export function getAddressPredictions(){
return(dispatch, store)=>{
let userInput = store().home.resultTypes.pickUp ? store().home.inputData.pickUp : store().home.inputData.dropOff;
RNGooglePlaces.getAutocompletePredictions(userInput,
{
country:"IND"
}
)
.then((results)=>
dispatch({
type:GET_ADDRESS_PREDICTIONS,
payload:results
})
)
.catch((error)=> console.log(error.message));
};
}
function handleGetAddressPredictions(state, action){
return update(state, {
predictions:{
$set:action.payload
}
})
}
const ACTION_HANDLERS = {
GET_ADDRESS_PREDICTIONS:handleGetAddressPredictions
}
Here is the custom listview to show the search in the based on the user input.
export const SearchResults = (predictions)=>{
return (
<View style={styles.searchResultsWrapper} >
<List
dataArray={predictions}
renderRow={(item)=>
<View>
<ListItem button avatar>
<Left style={styles.leftContainer}>
<Icon style={styles.leftIcon} name="location-on" />
</Left>
<Body>
<Text style={styles.primaryText}>{item.primaryText}</Text>
<Text style={styles.secondaryText}>{item.secondaryText}</Text>
</Body>
</ListItem>
</View>
}
/>
</View>
);
}
export default SearchResults;
The above code properly fetching the details in the console log but i am unable to return the valus in the listview.
If i replace the {item.primaryText} with hardcorded text, its getting displayed.
Log File
{home: {…}}
home:
inputData: {pickUp: "drive"}
predictions: Array(5)
0: {types: Array(2), placeID: "EkBEcml2ZSBJbiBSb2FkLCBTdW5yaXNlIFBhcmssIE1lbW5hZ2…6z6yEXjkRMJeafp9UzlASFAoSCYfkscixhF45ESTcwBLlzE9c", secondaryText: "Sunrise Park, Memnagar, Ahmedabad, Gujarat, India", primaryText: "Drive In Road", fullText: "Drive In Road, Sunrise Park, Memnagar, Ahmedabad, Gujarat, India"}
1: {types: Array(4), placeID: "ChIJ4dTf1U1mUjoRSSPy-3Y49qk", secondaryText: "Chennai, Tamil Nadu, India", primaryText: "Drivers Colony, T Nagar", fullText: "Drivers Colony, T Nagar, Chennai, Tamil Nadu, India"}
2: {types: Array(4), placeID: "ChIJRWoDFq6EXjkRCmo7r2rn_xw", secondaryText: "Sunrise Park, Gurukul, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Sunrise Park, Gurukul, Ahmedabad, Gujarat"}
3: {types: Array(4), placeID: "ChIJlaOzFK6EXjkR86sdRNqJgqY", secondaryText: "Nilmani Society, Thaltej, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Nilmani Society, Thaltej, Ahmedabad, Gujarat"}
4: {types: Array(1), placeID: "ChIJiVzj_YiUyzsRHgB632DAI44", secondaryText: "Financial District, Gachibowli, Hyderabad, Telangana, India", primaryText: "Driven Cafe", fullText: "Driven Cafe, Financial District, Gachibowli, Hyderabad, Telangana, India"}
length: 5
__proto__: Array(0)
region: {}
resultTypes: {pickUp: true, dropOff: false}
Expected result - Places should be displayed in the listview.
google-maps react-native react-native-maps
I am using the react-native-google-places to fetch the results based on the user input.
I can able to console log the search result based on the autocomplete user input, but it's not returning the value in my custom listview.
Code
export function getAddressPredictions(){
return(dispatch, store)=>{
let userInput = store().home.resultTypes.pickUp ? store().home.inputData.pickUp : store().home.inputData.dropOff;
RNGooglePlaces.getAutocompletePredictions(userInput,
{
country:"IND"
}
)
.then((results)=>
dispatch({
type:GET_ADDRESS_PREDICTIONS,
payload:results
})
)
.catch((error)=> console.log(error.message));
};
}
function handleGetAddressPredictions(state, action){
return update(state, {
predictions:{
$set:action.payload
}
})
}
const ACTION_HANDLERS = {
GET_ADDRESS_PREDICTIONS:handleGetAddressPredictions
}
Here is the custom listview to show the search in the based on the user input.
export const SearchResults = (predictions)=>{
return (
<View style={styles.searchResultsWrapper} >
<List
dataArray={predictions}
renderRow={(item)=>
<View>
<ListItem button avatar>
<Left style={styles.leftContainer}>
<Icon style={styles.leftIcon} name="location-on" />
</Left>
<Body>
<Text style={styles.primaryText}>{item.primaryText}</Text>
<Text style={styles.secondaryText}>{item.secondaryText}</Text>
</Body>
</ListItem>
</View>
}
/>
</View>
);
}
export default SearchResults;
The above code properly fetching the details in the console log but i am unable to return the valus in the listview.
If i replace the {item.primaryText} with hardcorded text, its getting displayed.
Log File
{home: {…}}
home:
inputData: {pickUp: "drive"}
predictions: Array(5)
0: {types: Array(2), placeID: "EkBEcml2ZSBJbiBSb2FkLCBTdW5yaXNlIFBhcmssIE1lbW5hZ2…6z6yEXjkRMJeafp9UzlASFAoSCYfkscixhF45ESTcwBLlzE9c", secondaryText: "Sunrise Park, Memnagar, Ahmedabad, Gujarat, India", primaryText: "Drive In Road", fullText: "Drive In Road, Sunrise Park, Memnagar, Ahmedabad, Gujarat, India"}
1: {types: Array(4), placeID: "ChIJ4dTf1U1mUjoRSSPy-3Y49qk", secondaryText: "Chennai, Tamil Nadu, India", primaryText: "Drivers Colony, T Nagar", fullText: "Drivers Colony, T Nagar, Chennai, Tamil Nadu, India"}
2: {types: Array(4), placeID: "ChIJRWoDFq6EXjkRCmo7r2rn_xw", secondaryText: "Sunrise Park, Gurukul, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Sunrise Park, Gurukul, Ahmedabad, Gujarat"}
3: {types: Array(4), placeID: "ChIJlaOzFK6EXjkR86sdRNqJgqY", secondaryText: "Nilmani Society, Thaltej, Ahmedabad, Gujarat", primaryText: "Drive In Cinema", fullText: "Drive In Cinema, Nilmani Society, Thaltej, Ahmedabad, Gujarat"}
4: {types: Array(1), placeID: "ChIJiVzj_YiUyzsRHgB632DAI44", secondaryText: "Financial District, Gachibowli, Hyderabad, Telangana, India", primaryText: "Driven Cafe", fullText: "Driven Cafe, Financial District, Gachibowli, Hyderabad, Telangana, India"}
length: 5
__proto__: Array(0)
region: {}
resultTypes: {pickUp: true, dropOff: false}
Expected result - Places should be displayed in the listview.
google-maps react-native react-native-maps
google-maps react-native react-native-maps
edited Jan 2 at 21:19
user2468312
asked Jan 2 at 19:26
user2468312user2468312
3719
3719
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012080%2freact-native-google-place-getautocompletepredictions-is-not-returning-the-valu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012080%2freact-native-google-place-getautocompletepredictions-is-not-returning-the-valu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown