Search code examples
reactjstypescriptjsxsolid-js

Text in view from function parameter


I want to show the text I pass into the parameter.

export default function Paragraph(text) {
   return(
      <div>
         {text}
      </div>
   )
}

But so far it doesn't render the text. I have even tried calling it as such

<Paragraph text="Some text"></Paragraph>

Solution

  • The Paragraph component should receive a "props" object argument, and the value of the "text" key should be obtained by destructuring the props object.

    export default function Paragraph({ text }) {
       return(
          <div>
             {text}
          </div>
       )
    }