SolidJSS
SolidJSโ€ข2y agoโ€ข
9 replies
gerard

Pass props from Component to props.children

function Child (props) { return <div class={props.class}>child</div> }

function Parent (props) {
 // I want parent to be able to customize the props passed to children here
 // like for example the css class
  return <div>{ props.children }</div>
}

function App () {
return (
 <Parent>
     <Child />
 </Parent>
)
}


Things that I have tried and do not work:

function Parent (props) {
  return <div>{ props.children({ class: "test" }) }</div>
}

function Parent (props) {
  return <div><Dynamic component={props.children} class="test" /></div>
}
Was this page helpful?