1

I have delete_task action that POST the task id to PHP file to delete the task , although the action I fired correctly and i see the effect in the console but the task not deleted, i tried many many times using GET OR POST OR JUST put the id statically in the URL but nothing changing,can anyone help me to solve the problem

tasksAction.js

export  const delete_task = id => ({
    type: DELETE_TASK,
    payload: {id},
    meta: {
        offline: {
            // the network action to execute:
            effect: { url: 'http://localhost/todos/remove.php', method: 'POST',body: {id} },
            // action to dispatch when effect succeeds:
            commit: { type: DELETE_SUCCESS, meta: { id } },
            // action to dispatch if network action fails permanently:
            rollback: { type: DELETE_FAILED, meta: { id } }
        }
    }
});

store.js

import React, { Component } from 'react';
import { applyMiddleware, createStore, compose } from 'redux';
import { offline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults';
import {Provider} from 'react-redux';
import logger from 'redux-logger';

import RootNavigator from "./config/routes";
import reducers from './reducers'


// store
const middleware = [];
if(process.env.NODE_ENV === 'development'){
    middleware.push(logger);
}
const store = createStore(
    reducers,
    undefined,
    compose(
        applyMiddleware(...middleware),
        offline(offlineConfig)
    )
);

export default class App extends Component {

    render() {
        return (
            <Provider store={store}>
            <RootNavigator />
            </Provider>

        )
    }
}

Logger Result

user1080247
  • 1,076
  • 4
  • 21
  • 51

1 Answers1

0

In the offline object inside prev state, does it say online: false?

If it does, and you're developing in an Android emulator, Wifi is not available on the emulator if you are using below API level 25, so redux-offline thinks you have no connection and will not make the initial network request.

This occurred to me after testing redux-offline in an iOS simulator and everything worked.

Hope this helps.

Eric
  • 543
  • 7
  • 17