Learn how to use the ‘branch’ and ‘renderNothing’ higher-order
components to render nothing when a certain prop condition is
met. Sometimes you only want to render a component when valid
props exist or are in a certain condition; ‘renderNothing’ is
an easy way to completely remove the component when you don’t
need to show it.

const userIsNotActive = ({ status }) => status !== 'active';
const hideIfNotActive = branch(userIsNotActive, renderNothing);const FeaturedUser = hideIfNotActive(({ name, status }) =><div><h3>Today's Featured User</h3><User name={ name } status={ status } /><hr /></div>
);

转载于:https://www.cnblogs.com/Answer1215/p/6863604.html

[Recompose] Render Nothing in Place of a Component using Recompose相关推荐

  1. [React Router v4] Conditionally Render a Route with the Switch Component

    We often want to render a Route conditionally within our application. In React Router v4, the Route ...

  2. React 的 PureComponent Vs Component

    一.它们几乎完全相同,但是PureComponent通过prop和state的浅比较来实现shouldComponentUpdate,某些情况下可以用PureComponent提升性能 1.所谓浅比较 ...

  3. React - children props 与 render props

    React - children props 与 render props 一. children props 1. 函数组件形式 2. 类组件形式 二. render props 1. 函数组件形式 ...

  4. Vue源码解读(五):render和VNode

    Vue 2.0 相比 Vue 1.0 最大的升级就是利用了虚拟DOM. 在 Vue 1.0 中视图的更新是纯响应式的.在进行响应式初始化的时候,一个响应式数据 key 会创建一个对应的 dep,这个 ...

  5. php render用法,使用render方法的图文详解

    这次给大家带来使用render方法的图文详解,使用render方法的注意事项有哪些,下面就是实战案例,一起来看一下. 先说一下对官网上demo的个人理解: Vue的render方法说明 hello w ...

  6. React中PureComponent和Component异同

        它们几乎完全相同,但是PureComponent通过prop和state的浅比较来实现shouldComponentUpdate,某些情况下可以用PureComponent提升性能 所谓浅比较 ...

  7. 编写react组件_React组件的“黄金法则”如何帮助您编写更好的代码

    编写react组件 以及钩子如何发挥作用 (And how hooks come into play) Recently I've adopted a new philosophy that chan ...

  8. 关于 react createFactory 的小技巧

    官网说明 React.createFactoryfactoryFunction createFactory(string/ReactClass type ) 复制代码 上面函数返回一个用于生成给定类型 ...

  9. 前端Reract面试题-------总结(经典)

    1.React 中 keys 的作用是什么? Keys 是 React 用于追踪哪些列表中元素被修改.被添加或者被移除的辅助标识. render () {return (‹ul›{this.state ...

最新文章

  1. 深度学习在不同领域的应用,我去,这也行!?
  2. 多目标检测跟踪文献代码汇总
  3. (转)iPhone wifi使用socket连接Internet
  4. kubernetes1.8.4 安装指南 -- 6. 安装kubernetes master
  5. 锐捷ap怎么设置_新房装修网络布线方案一:AC+AP模式,弱电箱只放光猫和集成AC...
  6. Modbus寄存器地址规则
  7. hypermesh安装包百度云_HYPERMESH11.0 64bt软件
  8. Atitit vue绑定json列表数据到表格最小简化培训版本 目录 1.1. 引入类库jq与vue 1 1.2. 获取ajax数据并推送到vue的内部自定义变量 1 1.3. 建立表格与vue变量
  9. XML语言学习2---方立勋教程DTD
  10. android 剪切并上传图片
  11. 使用Safari只要打开echarts图表的网址会使Safari未响应
  12. AHU校赛网赛解题报告
  13. html5 video断点续播,vue-video-player 断点续播的实现
  14. 详解typora配置华为云图床
  15. Python利用adb命令操作安卓手机批量打电话
  16. AI绘图:chatGpt,midjourney, discord
  17. Python数据预处理:机器学习、人工智能通用技术(1)
  18. 微信小程序 监听手势滑动切换页面
  19. 腾讯公关总监张军“青年睡觉言论”大翻车,惨遭网友“群攻”
  20. 【精选】小白是如何挖漏洞的(技巧篇)

热门文章

  1. Js计算间隔天数和Date对象
  2. MindManager脑图之项目管理甘特图
  3. InChatter系统开源聊天模块前奏曲
  4. SQL Server 2005 智能感知插件 - SQL Prompt 3.8.0.224
  5. Symbian S60 3rd中的能力说明
  6. SQL Server 2005 的nvarchar(max),varchar(max)来救火
  7. Android Wear 唤醒热词会比“你好,安卓”好吗?
  8. Codis 3.x 部署安装
  9. 线程同步--条件变量
  10. springmvc使用spring自带日期类型验证