Created
February 19, 2020 12:46
-
-
Save leandrojo/1accdc851b951162a7719658ca178dde to your computer and use it in GitHub Desktop.
Trecho em Typescript 101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import TableCommunity from 'rc-table'; | |
| import { GetComponentProps } from 'rc-table/lib/interface'; | |
| interface Props { | |
| columns: Array<{ | |
| [key: string]: any; | |
| }>; | |
| data: object[]; | |
| scroll?: object; | |
| style?: object; | |
| onRow?: GetComponentProps<object> | undefined; | |
| } | |
| const Table = ({ columns, data, ...props }: Props) => ( | |
| <TableCommunity | |
| columns={columns} | |
| components={{ | |
| header: { | |
| cell: Header, | |
| }, | |
| body: { | |
| cell: Cell, | |
| row: Row, | |
| }, | |
| }} | |
| data={data} | |
| {...props} | |
| /> | |
| ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Importando "tipagem" a partir de uma terceira parte. Seria essa uma abordagem comum?
Sempre que quero intermediar um componente, apenas para criar definições de estilo ou tratamento de dados, etc, eu estou tendo dificuldades em satisfazer a tipagem exatamente como esperado. Tem alguma dica para esses casos?