码迷,mamicode.com
首页 > 其他好文 > 详细

JXS In Depth

时间:2017-03-23 20:12:49      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:target   call   http   mon   operator   could   href   att   javascrip   

JXS In Depth

1、Spread Attributes

  If you already have props as an object, and you want to pass it in JSX, you can use ... as a "spread" operator to pass the whole props object. These two components are equivalent:

  技术分享

2、Functions as Children

  props.children可以是一个函数。只要render()最终返回的是jsx就行了。

  Normally, JavaScript expressions inserted in JSX will evaluate to a string, a React element, or a list of those things. However, props.children works just like any other prop in that it can pass any sort of data, not just the sorts that React knows how to render. For example, if you have a custom component, you could have it take a callback as props.children:

   技术分享
  Children passed to a custom component can be anything, as long as that component transforms them into something React can understand before rendering. This usage is not common, but it works if you want to stretch what JSX is capable of.
3、jsx中使用条件expression
  技术分享

参考:https://facebook.github.io/react/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized

JXS In Depth

标签:target   call   http   mon   operator   could   href   att   javascrip   

原文地址:http://www.cnblogs.com/tekkaman/p/6606804.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!