dmk99 / react-pdf-table

Storybook Available
https://dmk99.github.io/react-pdf-table
MIT License
153 stars 62 forks source link

Map Data #19

Closed juandavidlasso closed 4 years ago

juandavidlasso commented 4 years ago

How can I map data, I have this code but in the pdf it only shows me the header and not the data:

Suerte Área Variedad {datos.map(c => ( {c.suerte} {c.area} {c.variedad} ))}
dmk99 commented 4 years ago

Using the example provided you'd need to do something like this:

                <Table
                    data={[
                        {suerte: "", area: "", variedad: ""},
                        ...
                    ]}
                >
                    <TableHeader>
                        <TableCell>
                            Suerte
                        </TableCell>
                        <TableCell>
                             Área
                        </TableCell>
                        <TableCell>
                             Variedad
                        </TableCell>
                    </TableHeader>
                    <TableBody>
                        <DataTableCell getContent={(r) => r.suerte}/>
                        <DataTableCell getContent={(r) => r.area}/>
                        <DataTableCell getContent={(r) => r.variedad}/>
                    </TableBody>
                </Table>

This should then display a table with your headers and the data rows.

juandavidlasso commented 4 years ago

Perfect, I already worked as I wanted, thank you very much.