Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140190

Issue with passing data from custom hook in react-native

$
0
0

I've made a custom hook and I'm trying to pass data from it to my profile screen. When i console.log from the hook I get the output, however I never receive the data in my Profile screen. I've been at this for last few hours trying everything so any help is much appreciated!

Custom Hook:

import { useState } from 'react';
import useMatchDetails from '../hooks/useMatchDetails';


export default () => {
const [searchMatch, matchDetails, errorMatchDetails] = useMatchDetails()
const [matchDetailArray, setMatchDetailArray] = useState([])

console.log(matchDetailArray)

const searchArray = (matchArray) => {

    matchArray.forEach(element => {
        searchMatch(element)
        if(matchDetails) {
            setMatchDetailArray(matchDetailArray => [...matchDetailArray, matchDetails]);
        }


    });
}


return [searchArray,matchDetailArray];

Profile:

import React, {useState, useEffect} from 'react';
import {View, Button, Text, Image, StyleSheet, TouchableOpacity, FlatList } from 'react-                native';
import useLeague from '../hooks/useLeague';
import useMatchHistory from '../hooks/useMatchHistory';

import useMatchDetailArray from '../hooks/useMatchDetailArray';
import matchHistory from '../api/matchHistory';

const Profile = (props) => {
const id = props.navigation.getParam('id');
const puuid = props.navigation.getParam('puuid');

const [searchLeague, results, errorMessage] = useLeague()
const [searchMatchHistory, matchHistoryVar, errorMessageMatchHistory] = useMatchHistory()
const [searchArray,matchDetailArray] = useMatchDetailArray()

console.log(matchDetailArray)

Viewing all articles
Browse latest Browse all 140190


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>