简体   繁体   English

undefined-is-not-an-object-evaluating-this-state-datasource.map

[英]undefined-is-not-an-object-evaluating-this-state-datasource.map

componentDidMount(){
    fetch('https://boboboi.online/c_api_sales/get_dest',{
      method: 'POST',
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
              },
                body: JSON.stringify({
                        port_code: 'CP-002',
                        api_key: 'ae9a6ce9a7479038d998060ef6d65ca9f86a13ed962a5366b3b0662cc52dde1b',
                        token: 'a959190d43520f8017ed2ca09ffc61bb'
                }),
    })   
        .then((response) => response.json())
        .then((responseJson) => { 
            this.setState({
                isLoading: false,
                dataSource: responseJson
              }, function() {
                // In this block you can do something with new state.
              });
            })
            .catch((error) => {
              console.error(error);
            });
        }

        GetPickerSelectedItemValue=()=>{

            Alert.alert(this.state.PickerValueHolder);

          }

看法在此处输入图片说明

map() method can be used with array and not with object. map() 方法可以用于数组而不是对象。 So if you want to use map method you can try using it like Object.keys(this.state.dataSource).map((key, index)=> { //your function and logic });所以如果你想使用 map 方法,你可以尝试像 Object.keys(this.state.dataSource).map((key, index)=> { //your function and logic });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 undefined 不是一个对象(评估'this.state.markers.map')渲染 - undefined is not an object (evaluating 'this.state.markers.map') render TypeError: Undefined is not an object(评估'this.state.videos.map') - TypeError: Undefined is not an object (evaluating 'this.state.videos.map') 错误类型错误:未定义不是 object(正在评估“state.map”) - ERROR TypeError: undefined is not an object (evaluating 'state.map') undefined 不是一个对象(评估'_this.state') - undefined is not an object (evaluating '_this.state') ReactNative null不是对象(评估“ this.state.dataSource”) - ReactNative null is not an object (evaluating 'this.state.dataSource') 未定义不是评估this.state。*的对象。 - Undefined is not an object evaluating this.state.* 未定义不是对象(评估'this.state.input') - Undefined is not an object (evaluating 'this. state.input') TypeError: undefined is not an object(评估'this.state.imagesID') - TypeError: undefined is not an object (evaluating 'this.state.imagesID') React Native得到TypeError:undefined不是一个对象(正在评估'_this.state.apiData.items.map') - React Native getting TypeError: undefined is not an object(evaluating '_this.state.apiData.items.map') 未定义不是对象(评估this.state.name) - Undefined is not an object (evaluating this.state.name)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM