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

Listing Timelines with Pagination options doesn't work on React Native #890

Closed
Lisieshy opened this issue Apr 20, 2023 · 2 comments
Closed

Comments

@Lisieshy
Copy link

Hello!

I am using masto.js version 5.11.1 and React Native 0.71.6.

When I call the list functions of the timelines with pagination options like the docs say (limit, maxId, sinceId and minId) the request fails and leaves the following error:

 WARN  Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot assign to property 'search' which has only a getter
TypeError: Cannot assign to property 'search' which has only a getter

Here is the code used to call the function. Masto is accessed with a reducer, and the function works as expected when no parameters are passed.

const TestCall = async () => {
  const posts = await masto.v1.timelines.listHome({
    limit: 2,
  });
  console.log(posts);
}

return (
  <Button onPress={TestCall}>Call function</Button>
)
@neet
Copy link
Owner

neet commented Apr 20, 2023

Hi, thank you for reporting an issue. I'm sorry for the inconvenience.

I'm not very familiar with React Native, but one thing I've noticed is that it is throwing an error when Masto.js tried to use the search property of the URL object.

According to MDN, the search property is not read-only so we should be able to set another value for it, while React Native doesn't seem to be offering WHATWG-compatible URL objects facebook/react-native#16434.

I'm trying my best to make Masto.js a framework-agnostic library, but since it is also used in browser environments, it assumes that the runtime is at least compatible with WHATWG APIs in order to reduce the bundle size.

Therefore, could you try some third-party library that polyfills the URL object? I've found some:
https://www.npmjs.com/package/react-native-url-polyfill

@Lisieshy
Copy link
Author

I just tested the same code but now using the polyfill library you sent, and it now works as expected!

Thank you for the answer!

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

2 participants