Skip to content

Commit 97c087a

Browse files
committed
Move initial actions to module declarations
1 parent 14bfff6 commit 97c087a

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

src/core/app.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const mapStateToProps = ({ core }: CoreAwareState) => {
2626
};
2727

2828
const mapDispatchToProps = {
29-
loadTheme: actions.loadTheme,
3029
setTheme: actions.setTheme,
3130
};
3231

@@ -38,7 +37,6 @@ const App: React.FunctionComponent<Props> = (props) => {
3837
const {
3938
theme,
4039
loadingTheme,
41-
loadTheme,
4240
setTheme,
4341
} = props;
4442

@@ -48,10 +46,6 @@ const App: React.FunctionComponent<Props> = (props) => {
4846

4947
const themesMap = availableThemes;
5048

51-
useEffect(() => {
52-
loadTheme();
53-
}, [loadTheme]);
54-
5549
useEffect(() => {
5650
if (loadingTheme === false) {
5751
setMuiTheme(themesMap.get(theme));

src/core/core.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ISagaModule } from 'redux-dynamic-modules-saga';
22

3+
import { loadTheme } from './store/core.actions';
34
import coreReducer, { CoreState } from './store/core.reducer';
45
import coreSaga from './store/core.saga';
56

@@ -11,6 +12,8 @@ export const CoreModule: ISagaModule<CoreAwareState> = {
1112
id: 'core',
1213
reducerMap: { core: coreReducer },
1314
sagas: [coreSaga],
14-
initialActions: [],
15+
initialActions: [
16+
loadTheme(),
17+
],
1518
finalActions: [],
1619
};

src/hero/hero.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ISagaModule } from 'redux-dynamic-modules-saga';
22

3+
import { loadHeroes, loadPowers } from './store/hero.actions';
34
import heroReducer, { HeroState } from './store/hero.reducer';
45
import heroSaga from './store/hero.saga';
56

@@ -11,6 +12,9 @@ export const HeroModule: ISagaModule<HeroAwareState> = {
1112
id: 'hero',
1213
reducerMap: { hero: heroReducer },
1314
sagas: [heroSaga],
14-
initialActions: [],
15+
initialActions: [
16+
loadHeroes(),
17+
loadPowers(),
18+
],
1519
finalActions: [],
1620
};

src/hero/hero.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Box, Card, Hidden, Snackbar, Typography } from '@material-ui/core';
2-
import React, { useEffect } from 'react';
2+
import React from 'react';
33
import { connect, ConnectedProps } from 'react-redux';
44
import { DynamicModuleLoader } from 'redux-dynamic-modules';
55

@@ -23,8 +23,6 @@ const mapStateToProps = ({ hero }: HeroAwareState) => {
2323

2424
const mapDispatchToProps = {
2525
addHero: actions.addHero,
26-
loadHeroes: actions.loadHeroes,
27-
loadPowers: actions.loadPowers,
2826
hideSnackbar: actions.hideSnackbar,
2927
removeHero: actions.removeHero,
3028
setViewMode: actions.setViewMode,
@@ -45,20 +43,13 @@ const Hero: React.FunctionComponent<Props> = (props) => {
4543
snackbarOpen,
4644
viewMode,
4745
addHero,
48-
loadHeroes,
49-
loadPowers,
5046
hideSnackbar,
5147
removeHero,
5248
selectHero,
5349
setViewMode,
5450
updateHero,
5551
} = props;
5652

57-
useEffect(() => {
58-
loadHeroes();
59-
loadPowers();
60-
}, [loadHeroes, loadPowers]);
61-
6253
const onSnackbarClose = (event: React.SyntheticEvent | React.MouseEvent, reason?: string) => {
6354
if (reason !== 'clickaway') {
6455
hideSnackbar();

0 commit comments

Comments
 (0)