Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contributing to Twilio
Pull Request Details
JIRA link(s):
Description
This PR changes the type definition of the
roomproperty that is returned by theuseVideoContexthook: https://github.com/twilio/twilio-video-app-react/compare/change-room-type?expand=1#diff-5f7074762bdd254d26eb256ea66a88dbc94139ca26a510d9c3d3015817b4ea78R28The type is being changed from
RoomtoRoom | null.Previously, when the room type was just
Room, we would use a default value ofnew EventEmitter() as Roomfor theroomproperty before the user connected to a room, and after they disconnect from a room (see this line).I don't think that it is correct to use an empty event emitter as the value for
roomwhen the user is not connected to a room. Casting the empty event emitter to theRoomtype can make developers think that properties of the room object (likesidorlocalParticipant) are present when they actually aren't. In short, defining theroomproperty as typeRoomdoesn't accurately describe what theroomproperty is.Using a type of
Room | nullcan slightly increase the complexity of some hooks and components (some hooks and components now have to check for the existence of a room), but this type definition better describes what values are available when a user is not connected to a room. With this new type definition, room properties likesidorlocalParticipantmay not exist, which is accurate.Burndown
Before review
npm testBefore merge