0

I am looking at using the React-Bootstrap-Table module in my project. I want to wrap it in a React component called Table which will simply expose the react-bootstrap-module but also pull in the default stylesheet and a custom stylesheet. The wrapper component will live in a common UI-Kit so encapsulating it in this way will make it easier to use in other projects and prevent inconsistencies with css etc.

In a folder called Table I have the following @richsilv suggestion

index.js

import Table from './Table'

export default Table

Table.js

import * as ReactBootstrapTable from 'react-bootstrap-table'
import 'react-bootstrap-table/dist/react-bootstrap-table-all.min.css'
import './TableStyles.scss'

export default ReactBootstrapTable

I am then trying to import it into another component like so...

import { BootstrapTable, TableHeaderColumn } from '../Table'

This gives me the following error

Invariant Violation: Element type is invalid: expected a string (for
built-in components) or a class/function (for composite components) but 
got: undefined. You likely forgot to export your component from the
file  it's defined in. Check the render method of `ExportCSVTable`.

ExportCSVTable being the component I am trying to import Table into.

Strangely if I do

 import Table from '../Table'

the Table will render without issue. The only problem with that is that it fails linting because Table is defined but never used and any of the bootstrap table components are used but never defined. Plus it's just annoying that I can't destructure Table like I would do normally!

Hopefully it's a simple change to the way I am wrapping the module but any help would be greatly received.

Update

Error thrown after implementing @richsilv suggestion

enter image description here

bencrinkle
  • 278
  • 4
  • 13

1 Answers1

0

Apologies for wasting your time, I really should have read the question better. It's Table.js that needs to change:

import * as ReactBootstrapTable from 'react-bootstrap-table'
import 'react-bootstrap-table/dist/react-bootstrap-table-all.min.css'
import './TableStyles.scss'

export default ReactBootstrapTable
export * from 'react-bootstrap-table'

IGNORE BELOW

Try this:

import Table from './Table'~~

export default Table~~
export * from './Table'
richsilv
  • 7,993
  • 1
  • 23
  • 29