From 7ac707cd6b8db0b303de58206d0efacc089e4947 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Wed, 16 May 2018 23:38:31 +0800 Subject: [PATCH] Make 16/05 code review changes Changes not made: - Change of `Playground` component to an `SFC` --- src/actions/playground.ts | 7 +++---- src/components/Application.tsx | 2 +- src/components/Playground.tsx | 4 ++-- src/components/__tests__/Playground.tsx | 2 +- src/containers/PlaygroundContainer.ts | 4 ++-- src/reducers/playground.ts | 6 +----- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/actions/playground.ts b/src/actions/playground.ts index 97d541f4bd..4f3153f54c 100644 --- a/src/actions/playground.ts +++ b/src/actions/playground.ts @@ -4,7 +4,7 @@ import { Action, ActionCreator } from 'redux' * The `type` attribute for an `Action` which updates the `IPlaygroundState` * `editorValue` */ -export const UPDATE_EDITOR_VALUE: string = 'UPDATE_EDITOR_VALUE' +export const UPDATE_EDITOR_VALUE = 'UPDATE_EDITOR_VALUE' /** * Represents an `Action` which updates the `editorValue` of a @@ -13,8 +13,7 @@ export const UPDATE_EDITOR_VALUE: string = 'UPDATE_EDITOR_VALUE' * @property newEditorValue - The new string value for `editorValue` */ export interface IUpdateEditorValue extends Action { - type: string - newEditorValue: string + payload: string } /** @@ -23,5 +22,5 @@ export interface IUpdateEditorValue extends Action { */ export const updateEditorValue: ActionCreator = (newEditorValue: string) => ({ type: UPDATE_EDITOR_VALUE, - newEditorValue + payload: newEditorValue }) diff --git a/src/components/Application.tsx b/src/components/Application.tsx index 9ae4625916..0c670f16ce 100644 --- a/src/components/Application.tsx +++ b/src/components/Application.tsx @@ -11,7 +11,7 @@ export interface IApplicationProps extends RouteComponentProps<{}> { title: string } -const Application: React.SFC = (props: IApplicationProps) => { +const Application: React.SFC = (props) => { const redirectToDashboard = () => return ( diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index d0f6b332e1..f5215b2501 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -11,7 +11,7 @@ import 'brace/theme/github' */ export interface IPlaygroundProps { editorValue: string - updateCode: (newCode: string) => void + handleEditorChange: (newCode: string) => void } /** @@ -28,7 +28,7 @@ export default class Playground extends React.Component { mode="javascript" theme="github" value={this.props.editorValue} - onChange={this.props.updateCode} + onChange={this.props.handleEditorChange} /> ) diff --git a/src/components/__tests__/Playground.tsx b/src/components/__tests__/Playground.tsx index 865082b051..4c05c820ba 100644 --- a/src/components/__tests__/Playground.tsx +++ b/src/components/__tests__/Playground.tsx @@ -8,7 +8,7 @@ import { IPlaygroundProps as PlaygroundProps } from '../Playground' test('Playground renders correctly', () => { const props: PlaygroundProps = { editorValue: '', - updateCode: (newCode: string) => { + handleEditorChange: (newCode: string) => { return } } diff --git a/src/containers/PlaygroundContainer.ts b/src/containers/PlaygroundContainer.ts index e4313444ad..07dbfaf9e8 100644 --- a/src/containers/PlaygroundContainer.ts +++ b/src/containers/PlaygroundContainer.ts @@ -9,7 +9,7 @@ import { import { IState } from '../reducers' type StateProps = Pick -type DispatchProps = Pick +type DispatchProps = Pick /** Provides the editorValue of the `IPlaygroundState` of the `IState` as a * `StateProps` to the Playground component @@ -26,7 +26,7 @@ const mapStateToProps: MapStateToProps = state => { */ const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch) => { return { - updateCode: (newCode: string) => { + handleEditorChange: (newCode: string) => { dispatch(updateEditorValue(newCode)) } } diff --git a/src/reducers/playground.ts b/src/reducers/playground.ts index 59dbed520d..4fe3f957c4 100644 --- a/src/reducers/playground.ts +++ b/src/reducers/playground.ts @@ -1,10 +1,6 @@ import { Action, Reducer } from 'redux' import { IUpdateEditorValue, UPDATE_EDITOR_VALUE } from '../actions/playground' -/** - * A state for the playground container - * @property editorValue - The string content of the react-ace editor - */ export interface IPlaygroundState { editorValue: string } @@ -26,7 +22,7 @@ export const reducer: Reducer = (state = defaultState, action: case UPDATE_EDITOR_VALUE: return { ...state, - editorValue: (action as IUpdateEditorValue).newEditorValue + editorValue: (action as IUpdateEditorValue).payload } default: return state