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的更多相关文章

  1. [Recompose] Transform Props using Recompose --mapProps

    Learn how to use the 'mapProps' higher-order component to modify an existing component’s API (its pr ...

  2. [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 ...

  3. [Recompose] Stream Props to React Children with RxJS

    You can decouple the parent stream Component from the mapped React Component by using props.children ...

  4. 乘风破浪,遇见Android Jetpack之Compose声明式UI开发工具包,逐渐大一统的原生UI绘制体系

    什么是Android Jetpack https://developer.android.com/jetpack Android Jetpack是一个由多个库组成的套件,可帮助开发者遵循最佳做法.减少 ...

  5. [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 ...

  6. [Recompose] Compute Expensive Props Lazily using Recompose

    Learn how to use the 'withPropsOnChange' higher order component to help ensure that expensive prop c ...

  7. [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 ...

  8. [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 ...

  9. [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 ...

随机推荐

  1. ReactJs 入门DEMO(转自别人)

    附件是分享的一些他人的ReactJs入门DEMO,以前版本使用的是JSXTransformer.js,新版的用browser.min.js替代了. DEMO 下载地址:http://files.cnb ...

  2. 在window编写好的网站往linux上发布

    得知ASP.NET CORE可以跨平台,我内心很躁动,毕竟自己喜欢的,之前没有学过linux导致一开始上手linux有点困难,按照https://www.microsoft.com/net/core# ...

  3. [CSS] Build a Fluid Loading Animation in CSS

    In this lesson, we will create a fluid loading animation using Animations and Transformations in CSS ...

  4. 【Tomcat】严重: Context [/grouponAdminWeb] startup failed due to previous errors

    1 tomcat 6600启动报错[root@localhost webapps]#     sh /usr/local/apache-tomcat-6.0.37_6600/bin/startup.s ...

  5. 97.TCP通信

    运行截图: 客户端 创建通信套接字 //通信套接字,用于创建TCP连接 SOCKET socket_send; 创建tcp通信 //创建tcp通信 socket_send = socket(AF_IN ...

  6. ospp.vbs是什么文件?激活过程cscript ospp.vbs命令详解

    ospp.vbs是什么文件?激活过程cscript ospp.vbs命令详解 在Office 2013激活过程中我们经常会用到cscript ospp.vbs这个命令.那么,很有必要来了解一下,osp ...

  7. 【Codeforces Round #432 (Div. 2) B】Arpa and an exam about geometry

    [链接]h在这里写链接 [题意] 给你3个点A,B,C 问你能不能将纸绕着坐标轴上的一点旋转.使得A与B重合,B与C重合 [题解] 这3个点必须共圆. 则A,B,C不能为一条直线.否则无解. 共圆之后 ...

  8. (三)unity4.6Ugui中文教程文档-------概要-UGUI Basic Layout

     大家好,我是孙广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:http://www.unit ...

  9. PHP从数组中删除元素的四种方法实例

    PHP从数组中删除元素的四种方法实例 一.总结 一句话总结:unset(),array_splice(),array_diff(),array_diff_key() 二.PHP从数组中删除元素的四种方 ...

  10. ajax+客户端与服务器端的交互

    一. AJAX 原生JS var xhr=new XMLHttpRequest(); xhr.open("GET","[请求地址]",false); xhr.o ...