Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Type Props Example

function App() {
return (<div>
<Message text="rando text" />
    </div>
);
}

export default App;

type MessageProps ={
text: number

}

function Message({text}: MessageProps)
{

  return(<div>
  {text}
  </div>)
}

/*pop quiz, will the example below work?

type MessageProps ={
text: number

}
 
Answer: no, will produce an error due to wrong type
*/
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Type #Props #Example
ADD COMMENT
Topic
Name
8+7 =