monsterooo / blog

and make promises by the hours
MIT License
14 stars 1 forks source link

recompose flattenProp #14

Open monsterooo opened 6 years ago

monsterooo commented 6 years ago

flattenProp 介绍

flattenProp可以将props中的对象扁平化到props中,类似于结构{...props.obj}

flattenProp Flow Type

flattenProp(
  propName: string
): HigherOrderComponent

flattenProp 实例

const { compose, flattenProp } = Recompose;
const Foo = compose(
  flattenProp('obj'),
)(({ title, desc }) => (
  <div>{title}, {desc}</div>
));

在线DEMO

codepen在线预览