<Table> in react-bootstrap - SyntaxError

Viewed 109

I'm working on a React project using react-bootstrap, and having a problem when trying to add JSX before of after the <Table> part.

Someone familiar with that problem?

return (
    
    <h1>My Schedule</h1>
    
    <Table striped bordered hover>
      <thead>
        <tr>
          <th>Time</th>
          <th>Medicine Name</th>


SyntaxError: C:\Users\hardu\Desktop\Web Development\Medisafe\dashboard\src\pages\Schedule.js: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?(22:4)       

  20 |     <h1>My Schedule</h1>
  21 |
> 22 |     <Table striped bordered hover>
     |     ^
  23 |       <thead>
  24 |         <tr>
  25 |           <th>Time</th>

error

1 Answers

You have to wrap your jsx in a main div or a react fragment.

return (
    <>
    <h1>My Schedule</h1>
    
    <Table striped bordered hover>
      <thead>
        <tr>
          <th>Time</th>
          <th>Medicine Name</th>
         </>
Related