Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 reactjs.org #
 
PREVIOUS NEXT
Tagged: #Type #Props #Example
ADD COMMENT
Topic
Name
5+1 =