I am trying to get my hands on compound component pattern in ReactJS. And all is good but I am not able to export the component the way I want.
I have created one basic Table (Data Grid), which has many component like header, row, column, search, pagination etc.
And I want the end user to import this Table in this way.
import Table from './Table'
const DataGrid = () => {
return (
<Table>
<Table.Title></Table.Title>
<Table.Header>
<Table.Row></Table.Row>
</Table.Header>
<Table.Body>
<Table.Row></Table.Row>
</Table.Body>
</Table>
)
}
Now in component folder, I have one index.js file where I am trying to import all component and then trying to export it in a object
import {Table} from './Table'
import {Title} from './Title'
import {Header} from './Header'
import {Body} from './Body'
Now what should I do to export in a way I want. Tried many solutions, but nothing is working.
./Table? Specifically how you are exporting it