diff --git a/README.md b/README.md index 0793532..fa4182f 100644 --- a/README.md +++ b/README.md @@ -152,12 +152,12 @@ We'll write a `Hello.tsx`: import * as React from 'react'; -export interface Props { +export interface IProps { name: string; enthusiasmLevel?: number; } -function Hello({ name, enthusiasmLevel = 1 }: Props) { +function Hello({ name, enthusiasmLevel = 1 }: IProps) { if (enthusiasmLevel <= 0) { throw new Error('You could be a little more enthusiastic. :D'); } @@ -268,17 +268,17 @@ To do that, we're going to import * as React from "react"; -export interface Props { - name: string; +export interface IProps { + name?: string; enthusiasmLevel?: number; } -interface State { +interface IState { currentEnthusiasm: number; } -class Hello extends React.Component { - constructor(props: Props) { +class Hello extends React.Component { + constructor(props: IProps) { super(props); this.state = { currentEnthusiasm: props.enthusiasmLevel || 1 }; } @@ -491,7 +491,7 @@ For this, we can create a file called `src/types/index.tsx` which will contain d ```ts // src/types/index.tsx -export interface StoreState { +export interface IStoreState { languageName: string; enthusiasmLevel: number; } @@ -522,23 +522,23 @@ Next, we'll create a set of actions and functions that can create these actions ```ts import * as constants from '../constants'; -export interface IncrementEnthusiasm { +export interface IIncrementEnthusiasm { type: constants.INCREMENT_ENTHUSIASM; } -export interface DecrementEnthusiasm { +export interface IDecrementEnthusiasm { type: constants.DECREMENT_ENTHUSIASM; } -export type EnthusiasmAction = IncrementEnthusiasm | DecrementEnthusiasm; +export type EnthusiasmAction = IIncrementEnthusiasm | IDecrementEnthusiasm; -export function incrementEnthusiasm(): IncrementEnthusiasm { +export function incrementEnthusiasm(): IIncrementEnthusiasm { return { type: constants.INCREMENT_ENTHUSIASM } } -export function decrementEnthusiasm(): DecrementEnthusiasm { +export function decrementEnthusiasm(): IDecrementEnthusiasm { return { type: constants.DECREMENT_ENTHUSIASM } @@ -597,7 +597,7 @@ First let's update `src/components/Hello.tsx` so that it can modify state. We'll add two optional callback properties to `Props` named `onIncrement` and `onDecrement`: ```ts -export interface Props { +export interface IProps { name: string; enthusiasmLevel?: number; onIncrement?: () => void;