Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How to add json data to another screen react-native expo

$
0
0

I am using react-native and expo. As in the screenshot you can see that's how my first screen SearchScreen looks as. So when I click on the A (first one) it should redirect me to stock screen(as you can see in bottom of tabs) and add this symbol A. there. Could someone please tell me how to do that?

My code:

import React, { useState, useEffect } from "react";import {  StyleSheet,  View,  TouchableWithoutFeedback,  Keyboard,  FlatList,  TextInput,  Button,  Text,} from "react-native";import { useStocksContext } from "../contexts/StocksContext";import { scaleSize } from "../constants/Layout";import { Ionicons } from "@expo/vector-icons";import { ListItem } from "react-native";export default function SearchScreen({ navigation }) {  const { ServerURL, addToWatchlist } = useStocksContext();  const [state, setState] = useState({    /*  initial state here */    myListData: [],    search: "",  });  const [search, setSearch] = useState("");  useEffect(() => {    renderWithData();    // FixMe: fetch symbol names from the servner and save in local SearchScreen state  }, []);  updateSearch = (event) => {    setState({ search: event.target.value });  };  renderWithData = () => {    return fetch("http://131.181.190.87:3001/all")      .then((res) => res.json())      .then((json) => {        setState({          isLoaded: true,          myListData: json,        });        setTimeout(() => {          console.log(json);        }, 1000);      });  };  let movies = state.myListData.map((val) => {    return (<View key={val.symbol} style={styles.text}><Text style={styles.text}>{val.symbol}</Text><Text style={styles.text}>{val.name}</Text></View>    );  });  return (<TouchableWithoutFeedback onPress={Keyboard.dismiss}><View style={styles.container}><TextInput          style={styles.textinput}          placeholder="Search here"          placeholderTextColor="white"        /><Text>csdn</Text><View style={styles.text}>{movies}</View></View></TouchableWithoutFeedback>  );}const styles = StyleSheet.create({  textinput: {    color: "white",    height: "20",    fontSize: 18,  },  text: {    color: "white",    backgroundColor: "black",  },  flatstuff: {    color: "white",  },  // use scaleSize(x) to adjust sizes for small/large screens});

Below is the image (the link)SearchScreen


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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