当前位置:首页 > 开发 > 行业应用 > 正文

React Uncaught Invariant Violation: onlyChild must be passed a children with exa

发表于: 2016-05-14   作者:qiaolevip   来源:转载   浏览:
摘要: 报错提示: UncaughtInvariantViolation:onlyChildmustbepassedachildrenwithexactlyonechild.  报错代码: pmessage=this.state.showmessage?{this.state.pmessage}:""; return( {pmessage} );  解决方案:pmessage=t

报错提示:

 

Uncaught Invariant Violation: onlyChild must be passed a children with exactly one child.

 

 

报错代码:

 

pmessage = this.state.showmessage?<div className="pmessage">{this.state.pmessage}</div>:"";

return (
      <div className="userinfo">
        <TimeoutTransitionGroup enterTimeout={450} leaveTimeout={450} transitionName="pmessage" className='pmessage' >
          { pmessage }
        </TimeoutTransitionGroup>
      </div>
    );

 

 

解决方案:

pmessage = this.state.showmessage?<div className="pmessage">{this.state.pmessage}</div>:<div></div>; // 添加child DOM


return (
      <div className="userinfo">
        <TimeoutTransitionGroup enterTimeout={450} leaveTimeout={450} transitionName="pmessage" className='pmessage' >
          { pmessage }
        </TimeoutTransitionGroup>
      </div>
    );

 



有疑问或技术交流,扫描公众号一起讨论学习。

更多React在线学习访问:http://each.sinaapp.com/react/index.html

React Uncaught Invariant Violation: onlyChild must be passed a children with exa_第1张图片

React Uncaught Invariant Violation: onlyChild must be passed a children with exa

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
记录SQLite唯一主键的错误及解决方法,错误如标题中所示,违反了主键唯一性约束。 开发工具:VS 201
2 react
基于HTML的前端界面开发正变得越来越复杂,其本质问题基本都可以归结于如何将来自于服务器端或者用
React Native 用于构建用户界面的JAVASCRIPT库 | React React 入门实例教程 颠覆式前端UI开发框架:
文献分析:Learning hierarchical invariant spatio-temporal features for action recognition wit
This is a classic question of Java. Many similar questions have been asked on stackoverflow,
This is a classic question of Java. Many similar questions have been asked on stackoverflow,
1、React是什么? React是Facebook开源的一个用于构建用户界面的Javascript库,已经 应用于Facebook
写C/C++程序最怕出现这样的提示了,还好是在调试环境下显示出来的,在非调试状态就直接崩溃退出. 从上
写C/C++程序最怕出现这样的提示了,还好是在调试环境下显示出来的,在非调试状态就直接崩溃退出. 从上
项目中用到自定义Hibernate主键生成策略,并且主键生成有一定的规则 一:Entity定义 二:主键策略类
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号