React Component wait for required props to render

前端 未结 1 717
旧巷少年郎
旧巷少年郎 2021-02-09 00:36

I am declaring a component inside of a parent component. I want to establish specific props in one file, and then in the parent component, I want to be able to establish the oth

1条回答
  •  孤街浪徒
    2021-02-09 01:25

    You can use a conditional render statement to only render the child when the props are populated:

    let {foo, bar} = this.props;
    
    
        { foo && bar ?  : null }
    
    

    Or instead of null you could render a or something.

    0 讨论(0)
提交回复
热议问题