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
room
property that is returned by theuseVideoContext
hook: https://github.com/twilio/twilio-video-app-react/compare/change-room-type?expand=1#diff-5f7074762bdd254d26eb256ea66a88dbc94139ca26a510d9c3d3015817b4ea78R28The type is being changed from
Room
toRoom | null
.Previously, when the room type was just
Room
, we would use a default value ofnew EventEmitter() as Room
for theroom
property 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
room
when the user is not connected to a room. Casting the empty event emitter to theRoom
type can make developers think that properties of the room object (likesid
orlocalParticipant
) are present when they actually aren't. In short, defining theroom
property as typeRoom
doesn't accurately describe what theroom
property is.Using a type of
Room | null
can 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 likesid
orlocalParticipant
may not exist, which is accurate.Burndown
Before review
npm test
Before merge