在不让redux-thunk退回代码的情况下运作良好吗?

问题描述 投票:0回答:3
在我的项目中,我使用redux-thunk处理异步功能。编写函数的常规方法如下,>

return (dispatch) => { return fetchAPI().then(doSomething) }

但是我对fetchAPI函数之前是否没有'return'有疑问。这会对程序产生任何副作用吗?

return (dispatch) => { fetchAPI().then(doSomething) }

在我的项目中,我使用redux-thunk处理异步功能。编写函数的常规方法如下,return(dispatch)=> {return fetchAPI()。then(doSomething)} ...
reactjs react-redux redux-thunk
3个回答
1
投票
[fetchAPI().then(doSomething)返回Promise时,您可能想用它来检查其状态,例如,如果要在某处指示loading状态。

如果不使用该值,则不会带来任何影响。


0
投票
观看视频Redux Thunk Tricks

-1
投票
多个语句需要放在方括号中。单个表达式不需要括号。表达式也是函数的隐式返回值。
© www.soinside.com 2019 - 2024. All rights reserved.