Reactjs 道具在compose()中以哪种方式流动?

Reactjs 道具在compose()中以哪种方式流动?,reactjs,recompose,Reactjs,Recompose,考虑以下几点: const Foo = defaultProps({ foo: "foo" }); compose( Foo, LoadJson, RunParser )(Bar); 在这种情况下,propfoo是否通过LoadJson->RunParser->Bar向下流动?还是按相反的顺序,foo流经RunParser->LoadJson->Bar 有没有更好的方法从概念上设想这一点,而不是像那样的线性流程?正如您所看到的,道具从左到右流动,这意味

考虑以下几点:

const Foo = defaultProps({
        foo: "foo"
});

compose(
    Foo,
    LoadJson,
    RunParser
)(Bar);
在这种情况下,prop
foo
是否通过
LoadJson->RunParser->Bar
向下流动?还是按相反的顺序,
foo
流经
RunParser->LoadJson->Bar

有没有更好的方法从概念上设想这一点,而不是像那样的线性流程?

正如您所看到的,道具从左到右流动,这意味着左侧定义的道具对右侧的HOC可见。因此,在您的例子中,LoadJson和RunParser应该看到prop
foo

const enhance = compose(
    withProps({
    offset: 10,
  }),
  withState('count', 'updateCount', 0),
  withHandlers({
    increment: props => () => props.updateCount(n => n + 1 + props.offset),
    decrement: props => () => props.updateCount(n => n - 1)
  })
)

const Counter = enhance(({ count, increment, decrement }) =>
    <div>
    Count: {count}
    <div>
      <button onClick={increment}>+</button>
      <button onClick={decrement}>-</button>
    </div>
  </div>
)
const enhance=compose(
用道具({
抵销:10,
}),
带状态('count','updateCount',0),
带处理器({
增量:props=>()=>props.updateCount(n=>n+1+props.offset),
减量:props=>()=>props.updateCount(n=>n-1)
})
)
常量计数器=增强({计数、递增、递减})=>
计数:{Count}
+
-
)

在文档中,它说
从右到左组合函数。
所以我说它类似于
RunParser(LoadJson(Foo(Bar))。看,谢谢!这有助于函数调用的顺序,尽管我对道具如何流动仍然有点困惑。