Home > Mobile >  Passing Props to children, children is not a function
Passing Props to children, children is not a function

Time:11-15

Test.jsx

function Parent({ children }) {
    return <div>{children("Test")}</div>
}

function Test() {
    return (
      <Parent>
        { test => <div>{test}></div> }
      </Parent>
    )
}

Get an error saying children is not a function, But I see other examples on the internet saying this works. Anyone know why? On Preact X.

CodePudding user response:

Have you tried this one?

function Test() {
    return (
      <Parent children={test => <div>{test}></div>}/>
    )
}
  • Related