Skip to content

Commit

Permalink
fix flow errors caused by store prop in root (#1712)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikr01 authored and amilajack committed Aug 20, 2018
1 parent ef42688 commit 49c30b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
13 changes: 3 additions & 10 deletions app/actions/counter.js
@@ -1,9 +1,5 @@
// @flow
import type { counterStateType } from '../reducers/types';

type actionType = {
+type: string
};
import type { GetState, Dispatch } from '../reducers/types';

export const INCREMENT_COUNTER = 'INCREMENT_COUNTER';
export const DECREMENT_COUNTER = 'DECREMENT_COUNTER';
Expand All @@ -21,10 +17,7 @@ export function decrement() {
}

export function incrementIfOdd() {
return (
dispatch: (action: actionType) => void,
getState: () => counterStateType
) => {
return (dispatch: Dispatch, getState: GetState) => {
const { counter } = getState();

if (counter % 2 === 0) {
Expand All @@ -36,7 +29,7 @@ export function incrementIfOdd() {
}

export function incrementAsync(delay: number = 1000) {
return (dispatch: (action: actionType) => void) => {
return (dispatch: Dispatch) => {
setTimeout(() => {
dispatch(increment());
}, delay);
Expand Down
3 changes: 2 additions & 1 deletion app/containers/Root.js
Expand Up @@ -2,10 +2,11 @@
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import type { Store } from '../reducers/types';
import Routes from '../Routes';

type Props = {
store: {},
store: Store,
history: {}
};

Expand Down
7 changes: 2 additions & 5 deletions app/reducers/counter.js
@@ -1,11 +1,8 @@
// @flow
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../actions/counter';
import type { Action } from './types';

type actionType = {
+type: string
};

export default function counter(state: number = 0, action: actionType) {
export default function counter(state: number = 0, action: Action) {
switch (action.type) {
case INCREMENT_COUNTER:
return state + 1;
Expand Down
12 changes: 12 additions & 0 deletions app/reducers/types.js
@@ -1,3 +1,15 @@
import type { Dispatch as ReduxDispatch, Store as ReduxStore } from 'redux';

export type counterStateType = {
+counter: number
};

export type Action = {
+type: string
};

export type GetState = () => counterStateType;

export type Dispatch = ReduxDispatch<Action>;

export type Store = ReduxStore<GetState, Action>;

0 comments on commit 49c30b1

Please sign in to comment.