Skip to content

Commit

Permalink
Make 16/05 code review changes
Browse files Browse the repository at this point in the history
Changes not made:
- Change of `Playground` component to an `SFC`
  • Loading branch information
remo5000 committed May 16, 2018
1 parent b451e08 commit 7ac707c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/actions/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

/**
Expand All @@ -23,5 +22,5 @@ export interface IUpdateEditorValue extends Action {
*/
export const updateEditorValue: ActionCreator<IUpdateEditorValue> = (newEditorValue: string) => ({
type: UPDATE_EDITOR_VALUE,
newEditorValue
payload: newEditorValue
})
2 changes: 1 addition & 1 deletion src/components/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface IApplicationProps extends RouteComponentProps<{}> {
title: string
}

const Application: React.SFC<IApplicationProps> = (props: IApplicationProps) => {
const Application: React.SFC<IApplicationProps> = (props) => {
const redirectToDashboard = () => <Redirect to="/dashboard" />

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'brace/theme/github'
*/
export interface IPlaygroundProps {
editorValue: string
updateCode: (newCode: string) => void
handleEditorChange: (newCode: string) => void
}

/**
Expand All @@ -28,7 +28,7 @@ export default class Playground extends React.Component<IPlaygroundProps, {}> {
mode="javascript"
theme="github"
value={this.props.editorValue}
onChange={this.props.updateCode}
onChange={this.props.handleEditorChange}
/>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/containers/PlaygroundContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { IState } from '../reducers'

type StateProps = Pick<PlaygroundProps, 'editorValue'>
type DispatchProps = Pick<PlaygroundProps, 'updateCode'>
type DispatchProps = Pick<PlaygroundProps, 'handleEditorChange'>

/** Provides the editorValue of the `IPlaygroundState` of the `IState` as a
* `StateProps` to the Playground component
Expand All @@ -26,7 +26,7 @@ const mapStateToProps: MapStateToProps<StateProps, {}, IState> = state => {
*/
const mapDispatchToProps: MapDispatchToProps<DispatchProps, {}> = (dispatch: Dispatch<any>) => {
return {
updateCode: (newCode: string) => {
handleEditorChange: (newCode: string) => {
dispatch(updateEditorValue(newCode))
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/reducers/playground.ts
Original file line number Diff line number Diff line change
@@ -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
}
Expand All @@ -26,7 +22,7 @@ export const reducer: Reducer<IPlaygroundState> = (state = defaultState, action:
case UPDATE_EDITOR_VALUE:
return {
...state,
editorValue: (action as IUpdateEditorValue).newEditorValue
editorValue: (action as IUpdateEditorValue).payload
}
default:
return state
Expand Down

0 comments on commit 7ac707c

Please sign in to comment.