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
Issue with useRefract #153
Comments
Hey @jwentwistle thanks for reporting this! Could you provide some more information? Ideally a code example - that way we can better understand what's going wrong. A live codesandbox or something similar would be ideal! |
Okay, here's an issue from material, but they told me that it's not an issue with material. There's a code example in there. When looking at the code, an object with a symbol is passed into the subscribeTo function, but after the update, it's undefined. I don't know if it has to do with the polyfill of the symbol, but there are people that have made issues about that and I can't fix it. |
Hmm I can't figure out what your code is trying to do. const subscribeDiscussions = new Observable(subscriber => {
queryDiscussions.subscribe(
value => subscriber.next(value),
error => subscriber.error(error),
() => subscriber.complete()
);
return () => {
subscription.unsubscribe();
};
});
const observeUpdateDiscussions = ({ observe }, data) => {
return observe().pipe(take(1));
};
const handleUpdateDiscussions = initial => effect => {
effect.subscribe(query => {
if (mount && query.data) {
// detemines if update exists
let filterSub = userDiscussion.filter(object => {
return object._id == query.data.updateDiscussions._id;
});
// adds update if it doesn't exist
if (
query.data.updateDiscussions.type == "add" &&
filterSub.length == 0
) {
setUserDiscussion(userDiscuss => {
let update = [...userDiscuss, query.data.updateDiscussions];
client.writeQuery({
query: USERDISCUSSIONS,
data: { userDiscussions: update }
});
return update;
});
}
// deletes update if it does exist
if (query.data.updateDiscussions.type == "delete") {
setUserDiscussion(userDiscuss => {
let filterSubs = userDiscuss.filter(object => {
return object._id !== query.data.updateDiscussions._id;
});
client.writeQuery({
query: USERDISCUSSIONS,
data: { userDiscussions: filterSubs }
});
return filterSubs;
});
}
}
});
};
useRefract(observeUpdateDiscussions, subscribeDiscussions, {
handler: handleUpdateDiscussions
}); From what I can tell:
If that's the case, this is all set up just to wrap For example, this is much clearer to me: useEffect(() => {
queryDiscussions.subscribe(query => {
if (mount && query.data) {
// detemines if update exists
let filterSub = userDiscussion.filter(object => {
return object._id == query.data.updateDiscussions._id
})
// adds update if it doesn't exist
if (
query.data.updateDiscussions.type == 'add' &&
filterSub.length == 0
) {
setUserDiscussion(userDiscuss => {
let update = [...userDiscuss, query.data.updateDiscussions]
client.writeQuery({
query: USERDISCUSSIONS,
data: { userDiscussions: update },
})
return update
})
}
// deletes update if it does exist
if (query.data.updateDiscussions.type == 'delete') {
setUserDiscussion(userDiscuss => {
let filterSubs = userDiscuss.filter(object => {
return object._id !== query.data.updateDiscussions._id
})
client.writeQuery({
query: USERDISCUSSIONS,
data: { userDiscussions: filterSubs },
})
return filterSubs
})
}
}
})
}, []) Not saying that this is definitely a problem outside Refract, just trying to wrap my head around the problem and not getting it at this point! |
Thank you! That does fix it. I thought that refract was making react reactive. Although that issue with refract didn't happen until updating material. |
No problem! Yeah it makes react reactive - but specifically the
Interesting, I'll have to take a look at what their changelog was to see if there's anything which stands out! |
I'm gonna close this for now, since I've not been able to reproduce. If it comes up again please comment again or create a new issue! |
Hello,
I keep getting this error when I update material-ui from version 3.9.3 to 4.0.0.
The text was updated successfully, but these errors were encountered: