jdog
jdog

Reputation: 10759

What this TypeScript type annotation actually means?

I am trying to use this line of code but looks like its using typescript. My project is not. I need to make it work in ReactJS (newbie to JS and ReactJS). Just need to understand what this below means and how to make it reactjs compliant.

const VideoPreview = ({ stream }: { stream: MediaStream | null }) => {

Changing to this fixes it, but do NOT know what | null means?

const VideoPreview = ({ stream }) => {

Upvotes: 0

Views: 162

Answers (1)

Sowam
Sowam

Reputation: 1736

{ stream: MediaStream | null }

this line basically means that stream can be a type of MediaStream or null so || means it is OR, you can read about it here

Upvotes: 1

Related Questions