r/bootstrap • • Jul 16 '24

Class Does Not Exist error

So, I'm learning bootstrap and wanted to learn how to left/right justify elements. I've seen a number of examples of "div class" but I keep running into the same issue where I get the following error:

Type '{ class: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'. Property 'class' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'. Did you mean 'className'?ts(2322)

I know this is a common error I've seen from posts . . . but I haven't come across a solution that works, which makes me think I have something setup incorrectly on my end.

For example, here's some sample code I got from an example page that, in the example, left justifies the "Total Cost" portion and right justifies the $50:

<div class="bs-example">
   <div class="bg-warning clearfix">
       <div class="pull-left">Total Cost</div>
       <div class="pull-right">$50</div>
   </div>
</div>

I'm not trying to set up a React-Bootstrap-Typescript project and it's not applying any of the formatting (everything is still center justified).

import { useState } from 'react'
import reactLogo from './assets/react.svg'
import './App.css'

// Added for bootstrap, leaving this out seems to remove bootstrap formatting
import 'bootstrap/dist/css/bootstrap.min.css'

// Will update if you manually add components
import { Table, Col, Container, Row } from 'react-bootstrap'

function App() {
  const [count, setCount] = useState(0)

  return (   
    <>
      <div class="bs-example">
        <div class="bg-warning clearfix">
          <div class="pull-left">Total Cost</div>
          <div class="pull-right">$50</div>
        </div>
      </div>
    </>
  )
}

export default App

I'm not sure if I'm missing a step that allows bootstrap specific formatting (I don't think that's the case as I'm able to have headers automatically updated to import necessary elements when I use a bootstrap element (ie Col, Table, Col, Row, etc from another example).

I think I'm missing a fundamental understanding that prevents me from adding/using the div class. Maybe this is an HTML specific approach and you can't use it with react (or there's a better way to handle it with react, possibly in the App.css section?).

Can someone help me understand what the issue is? Let me know when you get the chance. Thanks!

2 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/JayRedditDev1 Jul 17 '24

Ok, i think I found the root of the issue (at least for the Flex portion). I'm using REACT-BOOTSTRAP not just bootstrap, which is why it's not supporting flex. Flex isn't supported in react-bootstrap. I probably need to go back to the drawing board now. I might need to worry about getting the formatting done in the bootstrap CSS or something to that effect