Skip to content

Commit

Permalink
docs(typescript): update to show functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Jan 23, 2022
1 parent a341bdf commit b7dfe38
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/documentation/typescript.md
Expand Up @@ -23,17 +23,20 @@ export const MyGame: Game<MyGameState> = {

### React

React components must include boardgame.io-specific properties, so extend your props from `BoardProps`:
React components must include boardgame.io-specific properties, so extend your
props from `BoardProps`. By passing your game state type to `BoardProps`,
you’ll get the correct typing for `G` in your board component.

```typescript
// Board.tsx
import type { BoardProps } from 'boardgame.io/react';
import type { MyGameState } from './Game.ts'

interface MyGameProps extends BoardProps {
// Custom properties for your component
interface MyGameProps extends BoardProps<MyGameState> {
// Additional custom properties for your component
}

export class MyGameBoard extends React.Component<MyGameProps> {
export function MyGameBoard(props: MyGameProps) {
// Your game board
}
```
Expand Down

0 comments on commit b7dfe38

Please sign in to comment.