I have a screen in my app which uses Context API reducers to fetch data from server on load. For this i have setup the code as follows. This is a functional component.
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>
Reducer
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);
I have verified that my dispatch method is working fine. However the newly created array is blank in the view’s return method. Whats more weird is if I console log propertyState I can see one record in the array, but if I console log propertyState.properties, I cannot see anything.
console.log(propertyState) console.log(propertyState.properties)