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

React Native support #5

Closed
madmod opened this issue Feb 25, 2020 · 5 comments
Closed

React Native support #5

madmod opened this issue Feb 25, 2020 · 5 comments
Assignees

Comments

@madmod
Copy link

madmod commented Feb 25, 2020

This module is really great. Is there any chance it could be made to support React Native? Maybe in PusherProvider it could use require and choose between pusher-js and pusher-js/react-native? Or you could pass in a custom Pusher and require pusher-js if one wasn't provided?

@mayteio
Copy link
Owner

mayteio commented Feb 25, 2020

Hey @madmod, glad you like it. I'd be happy to add RN support. I think following the convention of pusher is probably best, i.e.
import { PusherProvider } from "@harelpls/use-pusher/react-native".

In the meantime, you can pass your own value into the <PusherProvider /> like so:

import React from 'react'
import Pusher from 'pusher-js/react-native'
import { PusherProvider } from '@harelpls/use-pusher'

export const NativePusherProvider = props => {
  // store it in state so if you need to listen for auth changes
  // you can reinitialise and resubscribe to channels
  const [client] = useState(new Pusher("key", {}))

  return <PusherProvider value={{ client, triggerEndpoint: "" }} {...props} />
}

First class support would be ideal though. I'll stick it in the pipeline!

@mayteio mayteio self-assigned this Feb 25, 2020
@mayteio
Copy link
Owner

mayteio commented Mar 3, 2020

Hey @madmod, I have started this - you can track progress on #7

@mayteio
Copy link
Owner

mayteio commented Jun 23, 2020

Thanks for your patience here! React native support has been released at 5.0.0.

@mayteio mayteio closed this as completed Jun 23, 2020
@hsavit1
Copy link

hsavit1 commented Jun 25, 2020

great work @mayteio !

@mayteio
Copy link
Owner

mayteio commented Jun 25, 2020

Let me know how you go with it. I only wrote tests for it 🙃 didn’t use it in an actual example.

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