草庐IT

recompose

全部标签

javascript - 如何从重组转换为 Hook ?

我的公司正在使用重组作为我们的状态管理工具。我们正在重构我们的应用程序以使用Hook。对于下面的代码,您将如何用ReactHook组件替换recompose组件?理解为withState变成useState,如:withState('something','setSomething',null)成为const[something,setSomething]=useState(null);withProps、withHandlers、compose、hoistStatics和lifecycle会发生什么变化到?mapStateToProps和mapDispatchToProps是如何工作

javascript - 重组 "withReducer": justification of async reducer function call

我正在使用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

javascript - 如何在 Recompose 中使用 withHandlers 向功能组件添加引用并在 ScrollView 上调用 ScrollTo?

我的具体目标是使用ScrollTomethod一个ScrollView但保持功能组件结构。更一般地说,这需要获取对当前组件的引用isn'tpossiblewithnakedreactnative.2016年12月recompose添加了AllowshandlerspropertyofwithHandlerstobeafactoryfunction但我不太清楚如何正确使用它。如何在Recompose中使用withHandlers向功能组件添加引用并在ScrollView上调用ScrollTo? 最佳答案 你可以尝试这样的事情:/*..

javascript - 我如何在 React 的 recompose 生命周期方法中设置状态?

我在我的React项目中使用recomposehttps://github.com/acdlite/recompose/这是一个很棒的图书馆。我使用compose实用程序作为容器组件,将状态作为props传递给展示组件,如下所示:constenhance=compose(lifecycle({componentDidMount(){myCall.getResponse([productId]).then(products=>{setIsReady(true);});},}),withState('isAvailable','setIsAvailable',false),withStat