livekit / components-js

Official open source React components and examples for building with LiveKit.
https://livekit.io
Apache License 2.0
149 stars 64 forks source link

Add react-native package #826

Closed lukasIO closed 4 months ago

lukasIO commented 4 months ago

this PR re-exports specific state handling and context hooks that can be used within react-native without further modification.

There are some minor typing inconveniences, e.g.

function MyComponentsStage() {
  const tracks = useTracks([Track.Source.Camera]);

  console.log(tracks);

  return (
    <>
      {tracks.map((trackRef) => (
        <VideoView
          key={trackRef.participant.identity}
          videoTrack={trackRef.publication.track as VideoTrack | undefined}
        ></VideoView>
      ))}
    </>
  );
}

where we need to cast the publication.track as a VideoTrack right now as useTracks only returns general publications without being specific about the track type.

If we want to avoid people having to install yet another package, we can also think about doing the re-export of these hooks directly in the @livekit/react-native package that exists already today.

changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 4303f97b67775c91112d0b939fa3e30405ee4606

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | -------------------------------- | ----- | | @livekit/components-react-native | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 4 months ago

size-limit report 📦

Path Size
LiveKitRoom only 1.86 KB (0%)
LiveKitRoom with VideoConference 28.01 KB (0%)
All exports 33.04 KB (0%)
davidzhao commented 4 months ago

@davidliu what do you think? does this give you what you need to expose the hooks via RN?

davidliu commented 4 months ago

Will need to play more with it, but seems to work well. I think the only thing we'll want to add is a LiveKitRoom version for react native, since using useLiveKitRoom and setting up the context providers feels a little clunky.

lukasIO commented 4 months ago

I think the only thing we'll want to add is a LiveKitRoom version

totally agree!

Would you guys prefer releasing a separate package (the components-react-native one in this repo) or adding all these hooks to the already existing react-native package?

lukasIO commented 4 months ago

closing in favor of https://github.com/livekit/client-sdk-react-native/pull/139