Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: undefined is not an object (evaluating '_get2.queue') #55

Open
bijuC1983 opened this issue Jun 13, 2020 · 9 comments
Open

TypeError: undefined is not an object (evaluating '_get2.queue') #55

bijuC1983 opened this issue Jun 13, 2020 · 9 comments

Comments

@bijuC1983
Copy link

Hello,
I have setup as per your example project https://github.com/RobPando/offlineTweet.
I am getting proper isConnected NetInfo callbacks. The problem is i get the error:
image
This happens when
yield put({type: ONLINE});

I am using 0.61.5

@RobPando
Copy link
Member

Hey @bijuC1983 thanks for bringing this into attention. I use this in multiple projects and have not run into this issue. Could you provide more info so I can take a look at it please. Are you using redux sagas? what are you naming the offline reducer store? this offline: require('redux-offline-queue').reducer, ? and how are you declaring the offline actions? could you provide a snippet if possible.

@bijuC1983
Copy link
Author

Hello @RobPando. Thank you for your response. Yes, I am using redux-saga.
export default () => { const rootReducer = combineReducers({ //User user: persistReducer(userPersistConfig, UserReducer), //Patient patient: persistReducer(patientPersistConfig, PatientReducer), // Doctor doctor: persistReducer(doctorPersistConfig, DoctorReducer), master: MasterReducer, article: ArticleReducer, story: StoryReducer, comment: CommentReducer, call : CallReducer, appointment: AppointmentReducer, notification: NotificationReducer, transaction: TransactionReducer, offline: require('redux-offline-queue').reducer, });
Also, I was able to get this working by manually changing inside node_modules.
I changed,
var _get2 = (0, _lodash.get)(getState(), stateName),
to
var _get2 = (0, _lodash.get)(getState().toObject(), stateName),

@RobPando
Copy link
Member

@bijuC1983 this is great, really appreciate it. The curious thing is that getState should return an object. could you place a console log in there to see what getState() logs out please.

@bijuC1983
Copy link
Author

It does return an object in console. But, when I try to get any property('offline') from that object it returns undefined. It only works after toObject(). Please note I am on 0.61.5.
I also think #17 is related. And also this one
https://stackoverflow.com/questions/61956066/react-native-undefined-is-not-an-object-evaluating-get2-queue

@RobPando
Copy link
Member

Interesting, I will look into this. Thanks again!

@bijuC1983
Copy link
Author

Hello @RobPando I was wondering if you were able to have a look into it.
Also, I wanted to ask that is there a way I can manually add an action to the queue? What I would like to achieve is that if the network disconnects in the middle of a network operation (It was online when the action was fired), I would like to add the action to the queue when the network request times out.
I am using redux-saga and apisauce.
Any pointer will be really helpful.

@RobPando
Copy link
Member

@bijuC1983 I have not had a chance yet but I will this week. As for your question, I believe what you are trying to do is re-queue an action. There is a way to manually queue the action again, I use this for every offline request this is also good if the server is down for any reason and for your case also if it times out you can re-queue it. So if you are using redux-saga you can do something like this:

import { put, call } from "redux-saga/effects";
import { queueAction } from "redux-offline-queue";

function* postBlog(action) {
  cont { someParam } = action;
  const response = yield call(myAPI, someParam);

  if (response.ok) {
    // success
  else if (response.status === 500) {
    // server error
   // this manually adds the action back into the queue
    yield put(queueAction(action))
  } else {
    // client error do something else
  }
}

let me know if this helps

@fabcall
Copy link

fabcall commented Nov 13, 2020

@RobPando I wonder if theres a reasonable solution to put the action on top of the queue when it fails, when the order of the actions is relevant.

@RobPando
Copy link
Member

@fabcall sorry for the insanely late reply. I could split the queueing of action into 2 function a prepend and append function to queueing the action that way you can choose to queue your action to the top or at the bottom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants