[Recompose] Lock Props using Recompose -- withProps
Learn how to use the ‘withProps’ higher order component to pre-fill a prop, unable to be overridden.
const { Component } = React;
const { withProps } = Recompose; // with function as arguement
const HomeLink = withProps(({ query }) => ({ href: '#/?query=' + query }))('a');
// take object as arguement
const ProductsLink = withProps({ href: '#/products' })('a');
const CheckoutLink = withProps({ href: '#/checkout' })('a'); const App = () =>
<div className="App">
<header>
<HomeLink query="logo">Logo</HomeLink>
</header>
<nav>
<HomeLink>Home</HomeLink>
<ProductsLink>Products</ProductsLink>
<CheckoutLink>Checkout</CheckoutLink>
</nav>
</div>; ReactDOM.render(
<App />,
document.getElementById('main')
);
withProps, take string as arguement for creating a new DOM element.
[Recompose] Lock Props using Recompose -- withProps的更多相关文章
- [Recompose] Transform Props using Recompose --mapProps
Learn how to use the 'mapProps' higher-order component to modify an existing component’s API (its pr ...
- [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 ...
- [Recompose] Stream Props to React Children with RxJS
You can decouple the parent stream Component from the mapped React Component by using props.children ...
- 乘风破浪,遇见Android Jetpack之Compose声明式UI开发工具包,逐渐大一统的原生UI绘制体系
什么是Android Jetpack https://developer.android.com/jetpack Android Jetpack是一个由多个库组成的套件,可帮助开发者遵循最佳做法.减少 ...
- [Recompose] Create Stream Behaviors to Push Props in React Components with mapPropsStream
Rather than using Components to push streams into other Components, mapPropsStream allows you to cre ...
- [Recompose] Compute Expensive Props Lazily using Recompose
Learn how to use the 'withPropsOnChange' higher order component to help ensure that expensive prop c ...
- [Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose
This lesson takes the concept of render props and migrates it over to streaming props by keeping the ...
- [Recompose] Make Reusable React Props Streams with Lenses
If you hard-code a stream of props to target a specific prop, it becomes impossible to reuse that st ...
- [Recompose] Set the HTML Tag of a Component via a Prop using Recompose
Learn how to user the ‘componentFromProp’ helper and ‘defaultProps’ higher order component to swap t ...
随机推荐
- spark internal - 作业调度
作者:刘旭晖 Raymond 转载请注明出处 Email:colorant at 163.com BLOG:http://blog.csdn.net/colorant/ 在Spark中作业调度的相关类 ...
- 安卓View的缓冲机制
View组件显示的内容能够通过cache机制保存为bitmap, 主要有下面方法: void setDrawingCacheEnabled(boolean flag), Bitmap getDr ...
- js28--适配器模式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- js配合My97datepicker给日期添加天数
<input name="ctl00$ContentPlaceHolder1$txtTimeStart" type="text" value=" ...
- Android学习笔记进阶19之给图片加边框
//设置颜色 public void setColour(int color){ co = color; } //设置边框宽度 public void setBorderWidth(int width ...
- Linux下搭建JSP环境
Linux下搭建JSP环境 作为一名Java EE系统架构工程师,经常需要搭配和建立JSP(Java Server Pages)的开发环境和运行环境,所以本人在平时的工作中积累了一些在Linu ...
- 7.zookeeper集群搭建(windows环境下)
转自:https://www.cnblogs.com/xuxiuxiu/p/5868481.html 本次zk测试部署版本为3.4.6版本,下载地址http://mirrors.cnnic.cn/ap ...
- Python3的取余操作
https://blog.csdn.net/u014647208/article/details/53368244 取余代码: 输入以下代码: >>>10%2 >>> ...
- css结构设计思想
本文摘自博客园-予沁安的文章:结构化CSS设计思维,作为学习笔记记录一下 1.LESS.SASS等预处理器给CSS开发带来了语法的灵活和便利,其本身却没有给我们带来结构化设计思维.很少有人讨论CSS的 ...
- js里的表格数组某个key去重
如Elemgnt的table绑定的数据要某个key是唯一的 var myarry = [ {name: 'liuyang',age :13}, {name:'jike',age:15}, {name: ...