0
API에서 데이터를 가져 오는 여러 가지 동작이 내 응용 프로그램에 있습니다. 작업을 가져 오는 경우 내 redux 저장소에 "로드"속성을 설정 중입니다. 이제 앱에서 데이터를 가져 오는 네트워크 표시기를 보여주고 싶습니다. Redux를 사용하여 네트워크 표시기의 가시성을 설정할 위치는?
나는 빠른 & 더러운 해결책을 발견하지만 난이 그것을 할 수있는 방법이 아니라는 것을 확신 :import React, { Component } from 'react';
import { AppRegistry, StatusBar } from 'react-native';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducer from './app/reducers';
import App from './app/providers/App';
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const store = createStoreWithMiddleware(reducer);
class AppName extends Component {
render() {
store.subscribe(() => {
if(
store.getState().dishes.loading
|| store.getState().deals.loading
) StatusBar.setNetworkActivityIndicatorVisible(true);
else StatusBar.setNetworkActivityIndicatorVisible(false);
});
return (
<Provider store={store}>
<App />
</Provider>
);
}
}
AppRegistry.registerComponent('AppName',() => AppName);
이러한 청취자 후크하는 올바른 방법은 무엇입니까가?