-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Everyone likes to flow these days #52
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[libs] | ||
./flow-typed | ||
|
||
[options] | ||
module.name_mapper='^\(actions\|components\|constants\|containers\|reducers\|store\|test\)\/\(.*\)$' -> '<PROJECT_ROOT>/src/\1/\2' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,6 @@ dist | |
|
||
# Ignore logs | ||
npm-debug.log | ||
|
||
# Ignore flow | ||
flow-typed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import { APP_LOAD } from 'constants/action-types'; | ||
|
||
export function loadApp() { | ||
export type LoadApp = { | ||
type: 'APP_LOAD' | ||
} | ||
|
||
export function loadApp(): LoadApp { | ||
return { | ||
type: APP_LOAD, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import type { | ||
LoadApp | ||
} from './app'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module './app' import/no-unresolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module './app' import/no-unresolved |
||
|
||
export type ActionType = LoadApp; | ||
|
||
export type Dispatch = (action: ActionType) => void; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const APP_LOAD = 'APP_LOAD'; | ||
// @flow | ||
|
||
export const APP_LOAD: 'APP_LOAD' = 'APP_LOAD'; | ||
|
||
export default { APP_LOAD }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { loadApp } from 'actions/app'; | ||
import type { MapStateToProps } from 'react-redux'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'react-redux' import/no-unresolved |
||
import type { Dispatch } from 'actions/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'actions/index' import/no-unresolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'actions/index' import/no-unresolved |
||
import type { State } from 'reducers/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'reducers/index' import/no-unresolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'reducers/index' import/no-unresolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'reducers/index' import/no-unresolved |
||
import styles from './app.css'; | ||
|
||
type Props = { | ||
dispatch: () => void, | ||
type StateProps = { | ||
loaded: boolean | ||
} | ||
|
||
export class AppContainer extends Component { | ||
type Props = StateProps & { | ||
dispatch: Dispatch | ||
} | ||
|
||
export class AppContainer extends Component<Props> { | ||
componentDidMount() { | ||
this.props.dispatch(loadApp()); | ||
} | ||
const { dispatch } = this.props; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'dispatch' is missing in props validation react/prop-types |
||
|
||
props: Props; | ||
dispatch(loadApp()); | ||
} | ||
|
||
render() { | ||
if (!this.props.loaded) { | ||
const { loaded } = this.props; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'loaded' is missing in props validation react/prop-types |
||
|
||
if (!loaded) { | ||
return null; | ||
} | ||
|
||
|
@@ -26,10 +36,8 @@ export class AppContainer extends Component { | |
} | ||
} | ||
|
||
function mapStateToProperties(state) { | ||
return { | ||
loaded: state.app.loaded | ||
}; | ||
} | ||
const mapStateToProps: MapStateToProps<State, {}, StateProps> = (state) => ({ | ||
loaded: state.app.loaded | ||
}); | ||
|
||
export default connect(mapStateToProperties)(AppContainer); | ||
export default connect(mapStateToProps)(AppContainer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import React from 'react'; | ||
|
||
type Props = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import store from 'store'; | ||
import routes from 'routes'; | ||
import store from 'store/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'store/index' import/no-unresolved |
||
import routes from './routes'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module './routes' import/no-unresolved |
||
|
||
render( | ||
<Provider store={store}>{routes}</Provider>, | ||
document.getElementById('react') | ||
); | ||
const root = document.getElementById('react'); | ||
|
||
if (root) { | ||
render( | ||
<Provider store={store}>{routes}</Provider>, | ||
root | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import type { ActionType } from 'actions/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'actions/index' import/no-unresolved |
||
import { APP_LOAD } from 'constants/action-types'; | ||
|
||
const initialState = { | ||
loaded: false, | ||
export type AppState = { | ||
+loaded: boolean | ||
} | ||
|
||
const initialState: AppState = { | ||
loaded: false | ||
}; | ||
|
||
export default function app(state = initialState, action) { | ||
export default function app(state: AppState = initialState, action: ActionType) { | ||
switch (action.type) { | ||
case APP_LOAD: | ||
case APP_LOAD: { | ||
return { ...state, loaded: true }; | ||
} | ||
default: | ||
return state; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import type { Dispatch } from 'actions/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'actions/index' import/no-unresolved |
||
import type { AppState } from './app'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module './app' import/no-unresolved |
||
|
||
export { default as app } from './app'; | ||
|
||
export type State = { | ||
+app: AppState | ||
}; | ||
|
||
export type Store = { | ||
dispatch: Dispatch, | ||
getState: () => State, | ||
subscribe: (listener: () => void) => () => void | ||
}; | ||
|
||
export default {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
import React from 'react'; | ||
import { Switch, Route } from 'react-router'; | ||
import { ConnectedRouter } from 'connected-react-router'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// @flow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolve error: package.json not found in path import/no-unresolved |
||
|
||
// Create final store using all reducers and applying middleware | ||
import { createBrowserHistory } from 'history'; | ||
// Redux utility functions | ||
import { compose, createStore, combineReducers, applyMiddleware } from 'redux'; | ||
import { routerMiddleware, connectRouter } from 'connected-react-router'; | ||
// Import all reducers | ||
import * as reducers from 'reducers'; | ||
import * as reducers from 'reducers/index'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to resolve path to module 'reducers/index' import/no-unresolved |
||
|
||
// Configure reducer to store state at state.router | ||
// You can store it elsewhere by specifying a custom `routerStateSelector` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve error: package.json not found in path import/no-unresolved
Resolve error: package.json not found in path import/no-duplicates