我的公司正在使用重组作为我们的状态管理工具。我们正在重构我们的应用程序以使用Hook。对于下面的代码,您将如何用ReactHook组件替换recompose组件?理解为withState变成useState,如:withState('something','setSomething',null)成为const[something,setSomething]=useState(null);withProps、withHandlers、compose、hoistStatics和lifecycle会发生什么变化到?mapStateToProps和mapDispatchToProps是如何工作
我正在使用withReducerHOC并注意到这种行为:例如,在点击处理程序上调用它:importReactfrom'react'import{withReducer}from'recompose'import{compose}from'ramda'exportdefaultcompose(withReducer('state','dispatch',(state,{value})=>{console.log(value)return{...state,value}},{value:'zero'}))((props)=>{const{dispatch,state}=props,onCl
我的具体目标是使用ScrollTomethod一个ScrollView但保持功能组件结构。更一般地说,这需要获取对当前组件的引用isn'tpossiblewithnakedreactnative.2016年12月recompose添加了AllowshandlerspropertyofwithHandlerstobeafactoryfunction但我不太清楚如何正确使用它。如何在Recompose中使用withHandlers向功能组件添加引用并在ScrollView上调用ScrollTo? 最佳答案 你可以尝试这样的事情:/*..
我在我的React项目中使用recomposehttps://github.com/acdlite/recompose/这是一个很棒的图书馆。我使用compose实用程序作为容器组件,将状态作为props传递给展示组件,如下所示:constenhance=compose(lifecycle({componentDidMount(){myCall.getResponse([productId]).then(products=>{setIsReady(true);});},}),withState('isAvailable','setIsAvailable',false),withStat