[Recompose] Compute Expensive Props Lazily using Recompose
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>
- );
[Recompose] Compute Expensive Props Lazily using Recompose的更多相关文章
- react recompose
避免写嵌套 import { compose } from "recompose"; function Message(props) { const { classes } = p ...
- [Recompose] Stream a React Component from an Ajax Request with RxJS
Loading data using RxJS is simple using Observable.ajax. This lesson shows you how to take the ajax ...
- [Recompose] Configure Recompose to Build React Components from RxJS Streams
Recompose provides helper functions to stream props using an Observable library of your choice into ...
- SVM与LR的区别以及SVM的优缺点
对于异常数据,SVM比LR更好 SVM的优缺点: 优点:1.提供非常精确的分类器 2.更少的过拟合(因为有L2正则化项0.5||w||2),对噪声数据更加鲁棒(因为损失函数的原因) 缺点:1.SVM是 ...
- ML 激励函数 Activation Function (整理)
本文为内容整理,原文请看url链接,感谢几位博主知识来源 一.什么是激励函数 激励函数一般用于神经网络的层与层之间,上一层的输出通过激励函数的转换之后输入到下一层中.神经网络模型是非线性的,如果没有使 ...
- [Converge] Training Neural Networks
CS231n Winter 2016: Lecture 5: Neural Networks Part 2 CS231n Winter 2016: Lecture 6: Neural Networks ...
- react 使用的小建议
使用pureRender,setState和Immutable.js来操作state Immutable 中文意思不可变. 不能直接修改state的值,要用setState 和Immutable re ...
- Vue基础:子组件抽取与父子组件通信
在工作中承担一部分前端工作,主要使用Vue + Element UI. 随着版本迭代,需求增加,页面往往变得更加臃肿,不易维护.学习子组件的封装和抽取,能更好适应需求. 为什么需要子组件 可复用 将重 ...
- [Recompose] Compose Streams of React Props with Recompose’s compose and RxJS
Functions created with mapPropsStream canned be composed together to build up powerful streams. Brin ...
随机推荐
- Oracle数据库安装时 environment variable path 大于 1023
提示的内容如下: 打开系统的环境变量设置, 编辑Path,全选将其中的路径全部复制出来放到文本文档中.新建一个系统变量取名Path_Old_1,剪切Path中的所有变量复制进path1然后保存,将Pa ...
- HDOJ 5357 Easy Sequence DP
a[i] 表示以i字符开头的合法序列有多少个 b[i] 表示以i字符结尾的合法序列有多少个 up表示上一层的'('的相应位置 mt[i] i匹配的相应位置 c[i] 包括i字符的合法序列个数 c[i ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 托管代码(.NET)
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 托管代码(.NET) 在SP2010中,微软提 ...
- js-YDUI 移动端解决方案
/** * YDUI 可伸缩布局方案 * rem计算方式:设计图尺寸px / 100 = 实际rem 例: 100px = 1rem */ !function (window) { /* 设计图文档宽 ...
- 七、Docker+nginx
原文:七.Docker+nginx docker run -p 80:80 --name nginx-v1.0.0 -v /usr/nginx/www:/www -v /home/docker/ngi ...
- 一次Linux磁盘损坏导致系统不可用恢复实例
Linux操作系统的server重新启动后.系统启动报错,系统无法正常使用. 1.报错信息 1.1.报错屏幕信息 1.2.报错信息提取关键信息 (1)/dev/sda3:File -(inode #1 ...
- Android实现点击通知栏后,先启动应用再打开目标Activity
情况简述 在开发Android app的过程中,遇到这样一个需求:app中启动一个Service,该Service在独立进程中运行,与服务器保持长连接,将服务器推送过来的消息在通知栏中显示,并设置点击 ...
- matlab 文件路径问题
1. fullfile:路径补全 f = fullfile(filepart1,...,filepartN) 显然可变参数之间填充的路径分隔符(path separator),会根据操作系统而变化: ...
- 芯片TPS76030、TPS76032、TPS76033、TPS76038、TPS76050 电源芯片
下图是从网上摘出来的图片:TPS76033 它的作用就是改变电压: 输入电压:3.5V到16V 通过芯片的处理后 输出电压:3.3V 要学会看图,从中提取有用的信息 再看一个数据手 ...
- 学习笔记:Vue——混入
前言: 到现在用Vue做了不少项目了,用到的都是初阶的功能,很多高阶能力都没有用到.仅用初级阶段也能做项目,甚至是复杂项目,可见vue之强大,果然是渐进式开发方式. 但是本着虚心学习的态度,还是要抽空 ...