我如何从react-native中的另一个js文件访问变量

时间:2019-03-02 19:08:35

标签: react-native variables

我是本机反应的新手。这是App.js的一部分

<Button
    title="LOGIN"
    onPress={() => 
        {
         {{this.componentDidMount(this.state.city)}}
        }
    }
/>

我想将“ this.state.city”发送到我的其他js文件“ Form.js”。

这是'Form.js'

import React from 'react';
import { FlatList, ActivityIndicator, Text, View  } from 'react-native';

class Form extends React.Component {
  constructor(props){
    super(props);
    this.state ={ isLoading: true}
  }
  componentDidMount(){
    const api_key="there_is_an_api_key";
    const city="ankara"
    // I want that variable here

谢谢您的帮助

0 个答案:

没有答案
相关问题