Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UseonViewWillEnter未按预期工作-Ionic、ReactJS、Context API_Reactjs_Ionic Framework_Context Api - Fatal编程技术网

UseonViewWillEnter未按预期工作-Ionic、ReactJS、Context API

UseonViewWillEnter未按预期工作-Ionic、ReactJS、Context API,reactjs,ionic-framework,context-api,Reactjs,Ionic Framework,Context Api,我的应用程序中有一个屏幕,它使用上下文API还原程序从服务器上获取加载数据。为此,我设置了如下代码。这是一个功能组件 const refreshView = () => { propertyDispatch({ type: "GETPROPERTYS", mobileNumber: contextValue.mobileNumber, }); }; useIonViewWillEnter(() => { r

我的应用程序中有一个屏幕,它使用上下文API还原程序从服务器上获取加载数据。为此,我设置了如下代码。这是一个功能组件

const refreshView = () => {
    propertyDispatch({
      type: "GETPROPERTYS",
      mobileNumber: contextValue.mobileNumber,
    });
  };

  useIonViewWillEnter(() => {
    refreshView();
  });


<IonContent fullscreen>
          {console.log({ render: propertyState })}
          {propertyState.properties! && (
            <IonGrid>
              {propertyState.properties!.map((property: any) => (
                <IonRow key={property.propertyID}>
                  <IonCol>
我已经证实我的调度方法运行良好。但是,新创建的数组在视图的返回方法中为空。更奇怪的是,如果我控制台记录propertyState,我可以看到数组中的一条记录,但是如果我控制台记录propertyState.properties,我什么都看不到

console.log(propertyState) 日志(propertyState.properties)

    switch (action.type) {
        case "GETPROPERTYS": {
          propertyservices.getPropertys(action.mobileNumber).then((response) => {
            let propes = [...response.data[0]];
            console.log(props);
            newData.properties = [];
            propes.map((p) => {
              let property = {};
              property.name = p.PropertyName;
newData.properties.push(property);