Learn how to use the 'withPropsOnChange' higher order component to help ensure that expensive prop computations are only executed when necessary. Simply specify which props are “expensive” and provide a factory function for those props.

withPropsOnChange(
shouldMapOrKeys: Array<string> | (props: Object, nextProps: Object) => boolean,
createProps: (ownerProps: Object) => Object
): HigherOrderComponent

Instead of an array of prop keys, the first parameter can also be a function that returns a boolean, given the current props and the next props. This allows you to customize when createProps() should be called.

const { Component } = React;
const { withPropsOnChange, withState, withHandlers, compose } = Recompose; // only generate 'result' when depth changed
const lazyResult = withPropsOnChange(
['depth'],
({ depth }) => ({
result: fibonacci(depth)
})
); const Fibonacci = lazyResult(({ result, color, size }) =>
<div style={{ color, fontSize: size }}>
Fibonacci Result:<br/>{ result }
</div>
);

最新文章

  1. MVC _ aspx视图引擎登录及状态保持
  2. C# inline-asm / 嵌入x86汇编
  3. Unity3D 实现简单的语音聊天 [iOS版本]
  4. 【SPOJ】7258. Lexicographical Substring Search(后缀自动机)
  5. AllocateHwnd is not Thread-Safe
  6. java中Object相关的几个方法
  7. solrCloud+tomcat+zookeeper配置
  8. 获取select选中的值
  9. 聊聊RocksDB Compact
  10. 【JS】jquery通知插件toastr
  11. 使用node操作mongodb
  12. Web App Checklist
  13. 栈帧 2.6. Frames 虚拟机内存模型
  14. MySQL内核整理(一)
  15. Python 列表 reverse() 方法
  16. mysql之SQLYog配置
  17. Java 堆栈,内存分配理解
  18. 【bootstrap】.container与.container_fluid
  19. [写出来才有价值系列:node.js]node.js 02-,learnyounode
  20. JDBC 事务(一) 隔离级别

热门文章

  1. HDFS简单介绍及用C语言訪问HDFS接口操作实践
  2. JXL.jar简单封装Excel读写操作
  3. GBX的Graph(最短路)
  4. Django路由分配以及模版渲染
  5. 洛谷 P1109 学生分组
  6. [Node &amp; Tests] Intergration tests for Authentication
  7. JQuery的index()函数
  8. 如何将String类型转换成任意基本类型
  9. 原生js大总结十一
  10. Codeforces 232A - Cycles (构造 + 思维)