Javascript 在React Native中反映更新设置间隔(函数()

Javascript 在React Native中反映更新设置间隔(函数(),javascript,ios,react-native,redux,Javascript,Ios,React Native,Redux,我想知道是否有一种方法可以在api数据发生更改时,以一定的间隔进行api调用并更新视图 我的部分代码看起来像 index.ios.js .... import App from './src/components/app'; import reducers from './src/reducers'; import { getData } from './src/actions/index'; const composeEnhancer = window.__REDUX_DEVTOOLS_EX

我想知道是否有一种方法可以在api数据发生更改时,以一定的间隔进行api调用并更新视图

我的部分代码看起来像

index.ios.js

....
import App from './src/components/app';
import reducers from './src/reducers';
import { getData } from './src/actions/index';

const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers, composeEnhancer(applyMiddleware(ReduxPromise, ReduxThunk)));
store.dispatch(getData());

class MyApp extends Component {
  render() {
    return (
      <Provider store={store}>
        <App />
      </Provider>
    );
  }
}

AppRegistry.registerComponent.....
。。。。
从“./src/components/App”导入应用程序;
从“/src/reducers”导入减速机;
从“./src/actions/index”导入{getData};
const composeinhancer=window.uuu REDUX_vtools_uextension_u124;COMPOSE|COMPOSE;
const store=createStore(还原器、复合器(applyMiddleware(ReduxPromise、ReduxThunk));
store.dispatch(getData());
类MyApp扩展组件{
render(){
返回(
);
}
}
AppRegistry.registerComponent。。。。。
因此,
store.dispatch(getData())
最初会进行一个api调用,我可以使用redux(this.props.data..类似这样的东西)在容器中显示数据

我尝试使用类似于
store.dispatch(setInterval(getData()),30000)的间隔进行api调用
,但它给了我一个错误,告诉我
undefined不是对象(计算'func.apply')

如果有人以前有过这种问题,或者知道在这种情况下该怎么办,请告诉我


感谢您在advanced中的支持。

尝试将
setInterval
置于
dispatch
之外。您是否考虑过使用其他中间件来协调您的副作用?我通常用一种很好的方法。我对redux-thunk/redux-promise很有偏见。@MattWay我试过,但它给了我同样的错误。@Josep以前从未使用过。我来看看。谢谢:)@MattWay实际上,nvm。我和setInterval玩了一圈,让它开始工作。非常感谢你!!