Using transmit-client with React-Native App #4488
-
Hi, is there a way to make transmit-client library to work with react-native? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I think, React Native doesnt have a builtin EventSource API So what you can do is use this package https://github.com/binaryminds/react-native-sse which provides an EventSource for react native, and pass it in when creating your transmit client instance import EventSource from "react-native-sse";
const transmit = new Transmit({
baseUrl: 'http://localhost:3333/',
eventSourceConstructor: EventSource
}) And it should work fine |
Beta Was this translation helpful? Give feedback.
-
@Julien-R44 thank you! |
Beta Was this translation helpful? Give feedback.
-
@Julien-R44 this approach throws "Invalid Package Error" :/ Any idea? The stack trace: `Metro has encountered an error: While trying to resolve module @adonisjs/transmit-client from file /Users/user/Documents/Projects/Meyouw/App/pages/launch/index.js , the package /Users/user/Documents/Projects/Meyouw/node_modules/@adonisjs/transmit-client/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved ( /Users/user/Documents/Projects/Meyouw/node_modules/@adonisjs/transmit-client/build/transmit.js . Indeed, none of these files exist:
287 | } RCTFatal |
Beta Was this translation helpful? Give feedback.
I think, React Native doesnt have a builtin EventSource API
So what you can do is use this package https://github.com/binaryminds/react-native-sse which provides an EventSource for react native, and pass it in when creating your transmit client instance
And it should work fine