I'm new to React, so maybe I'm missing something here, but I want to use the Panel
component from react-bootstrap
. I'm following the documentation, but getting the following behavior.
This code works:
import { Panel } from 'react-bootstrap';
(...)
return ( # This is inside my component's render()
<Panel>
Foo
</Panel>
)
This code doesn't work:
import { Panel } from 'react-bootstrap';
(...)
return ( # This is inside my component's render()
<Panel>
<Panel.Body>Foo</Panel.Body>
</Panel>
)
The error says: Uncaught Error: 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 (ComponentName)
.
What am I doing wrong? Many thanks!
react 15.6.2, react-bootstrap 0.31.5
React Bootstrap 5 Panels - examples & tutorial. Bootstrap React panels are bordered boxes where you can place texts, lists, tables and other content. Panels are similar to cards, but they don't include media. Panels are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization.
A panel in bootstrap is a bordered box with some padding around its content: Panels are created with the .panel class, and content inside the panel has a .panel-body class: The .panel-default class is used to style the color of the panel. See the last example on this page for more contextual classes.
It was in the particular version of react-bootstrap, we were using 0.31.5 and you used 0.32, so that directed me to the cause of the problem. Apparently react-bootstrap 's API was changed between the versions.
The React component model gives us more control over form and function of each component. Each component is implemented with accessibility in mind. The result is a set of accessible-by-default components, over what is possible from plain Bootstrap.
Please change to:import Panel from 'react-bootstrap/lib/Panel'
When importing from react-bootstrap
you need to import the component from the lib folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With