Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap is not working in ReactJS code

I want to use Bootstrap for creating a table in ReactJS. I have written the code bellow and have used class="container" in <div> and class="table table-striped" in <table> but the bootstrap is not working in this code. Please tell what can be the issue?

app.js

render : function() {
        return (
            <div class="container">
                <table class="table table-striped">
                    <tbody>
                    {this.state.rows.map((r) => (
                        <tr>
                            <td>{r}</td>
                            <td>
                                <button onClick={() => this.deleteRow(r)}>Delete</button>
                            </td>
                        </tr>
                    ))}
                    </tbody>
                </table>
                <input trype="text" id={"newVal"} onChange={this.updateNewValue}></input>
                <button id="addBtn" onClick={this.addRow}>ADD</button>
            </div>
        );
    },

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sample Project</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    <link href="http://maxcdn.bootstrapcdn.com/bootswatch/3.3.4/flatly/bootstrap.min.css" type="text/css" rel="stylesheet" />

    <script src="app.js" type="text/babel"></script>
</head>
<body>
    <div id="display"></div>
</body>
</html>
like image 622
Agha Avatar asked Oct 15 '25 23:10

Agha


1 Answers

Import Bootstrap CSS and optionally Bootstrap theme CSS at the beginning of your src/index.js file:

import 'bootstrap/dist/css/bootstrap.css';
like image 127
thanusiya nesarajan Avatar answered Oct 18 '25 13:10

thanusiya nesarajan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!