Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应-从返回条件中删除空DIV_Javascript_Reactjs_Ecmascript 6 - Fatal编程技术网

Javascript 反应-从返回条件中删除空DIV

Javascript 反应-从返回条件中删除空DIV,javascript,reactjs,ecmascript-6,Javascript,Reactjs,Ecmascript 6,我正在尝试从html中删除此空 class ParentComp extends Component { ... return ( <div> { GlobalAppHandlerStore.getCurrentState().countryCode === this.props.countryCode ? this.props.children : ''

我正在尝试从html中删除此空

class ParentComp extends Component {
...

return (
      <div>
        {
          GlobalAppHandlerStore.getCurrentState().countryCode === this.props.countryCode ?
            this.props.children
            :
            ''
        }
      </div>
    );
类ParentComp扩展组件{ ... 返回( { GlobalAppHandlerStore.getCurrentState().countryCode==this.props.countryCode? 这是道具 : '' } ); 用例:

<ParentComp countryCode={COUNTRY_CODE.be.value}>
   <ItemConfigure {...this.props} />
</ParentComp>

如果不匹配,则打印为空。

尝试以下操作:

render() {
    return GlobalAppHandlerStore.getCurrentState().countryCode === this.props.countryCode && (<div>{this.props.children}</div>);
}
render(){
返回GlobalAppHandlerStore.getCurrentState().countryCode==this.props.countryCode&({this.props.children});
}
试试这个:

render() {
    return GlobalAppHandlerStore.getCurrentState().countryCode === this.props.countryCode && (<div>{this.props.children}</div>);
}
render(){
返回GlobalAppHandlerStore.getCurrentState().countryCode==this.props.countryCode&({this.props.children});
}

您能显示您得到的结果的示例以及您希望准确显示的内容吗?在任何情况下,我通常会默认为
null
,而不是组件JSX中三元运算符的空字符串。例如:
条件?内容:null
,但您只需执行以下操作:GlobalAppHandlerStore.getCurrentState().countryCode==this.props.countryCode&({this.props.children})您能否显示您正在获得的结果的示例以及您希望准确显示的内容?在任何情况下,我通常会将组件JSX中的三元运算符默认为
null
,而不是空字符串。例如:
condition?Content:null
,但您只需执行以下操作:GlobalAppHandlerStore.getCurrentState().countryCode==this.props.countryCode&({this.props.children})