React Bootstrap encountered rendering issues

Recently, I decided to delve into the world of React Bootstrap and started my learning journey.

To get started, I followed some tutorials on

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Demo</title>
    <link rel="stylesheet" href="bootstrap-3.3.5-dist/css/bootstrap.min.css"/>
    <script src="js/react-0.13.3/build/react.min.js"></script>
    <script src="js/react-bootstrap.min.js"></script>
    <script src="js/react-0.13.3/build/JSXTransformer.js"></script>
    <script src="js/jquery-2.1.4.min.js"></script>
    <script src="demo_bootstrap_react.js" type="text/jsx"></script>
</head>
<body>
    <div id="test"></div>
</body>
</html>

After that, I attempted to replicate a tutorial for creating React Bootstrap Buttons:

const buttonsInstance = (
  <ButtonToolbar>
    {/* Standard button */}
    <Button>Default</Button>

    {/* Provides extra visual weight and identifies the primary action in a set of buttons */}
    <Button bsStyle="primary">Primary</Button>

    {/* Indicates a successful or positive action */}
    <Button bsStyle="success">Success</Button>

    {/* Contextual button for informational alert messages */}
    <Button bsStyle="info">Info</Button>

    {/* Indicates caution should be taken with this action */}
    <Button bsStyle="warning">Warning</Button>

    {/* Indicates a dangerous or potentially negative action */}
    <Button bsStyle="danger">Danger</Button>

    {/* Deemphasize a button by making it look like a link while maintaining button behavior */}
    <Button bsStyle="link">Link</Button>
  </ButtonToolbar>
);

ReactDOM.render(buttonsInstance, mountNode);

I encountered an issue where nothing was being rendered. It's frustrating as I already included React Bootstrap in the HTML file. What am I missing here? This shouldn't be happening!

Answer №1

To access all the components in ReactBootstrap when loading the distribution bundle without CommonJS or AMD, you will need to use the global ReactBootstrap.

Modify your example code as follows:

const buttonsInstance = (
  <ReactBootstrap.ButtonToolbar>
    {/* Standard button */}
    <ReactBootstrap.Button>Default</ReactBootstrap.Button>

    {/* Provides extra visual weight and identifies the primary action in a set of buttons */}
    <ReactBootstrap.Button bsStyle="primary">Primary</ReactBootstrap.Button>

    {/* Indicates a successful or positive action */}
    <ReactBootstrap.Button bsStyle="success">Success</ReactBootstrap.Button>

    {/* Contextual button for informational alert messages */}
    <ReactBootstrap.Button bsStyle="info">Info</ReactBootstrap.Button>

    {/* Indicates caution should be taken with this action */}
    <ReactBootstrap.Button bsStyle="warning">Warning</ReactBootstrap.Button>

    {/* Indicates a dangerous or potentially negative action */}
    <ReactBootstrap.Button bsStyle="danger">Danger</ReactBootstrap.Button>

    {/* Deemphasize a button by making it look like a link while maintaining button behavior */}
    <ReactBootstrap.Button bsStyle="link">Link</ReactBootstrap.Button>
  </ReactBootstrap.ButtonToolbar>
);

ReactDOM.render(buttonsInstance, mountNode);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to identify when no rows contain specific values in PostgreSQL or node.js and return false?

Here is an example of a table: P Q t f f t f f In SQL, is there a way to return false when querying for t t, but true when querying for t f, f t, or f f? Should this be handled with node.js by first doing a select and then using if-else statements based ...

Dynamic height of a fixed-positioned Div

I encountered an issue with a Fixed positioned DIV that has dynamically appended content using jQuery. Once the height of the DIV exceeds the screen size, I am unable to view the contents at the bottom of the DIV without zooming in using the browser' ...

To prevent the default alignment in case the text exceeds the input length, stop the automatic alignment

I have a query regarding an input field with a maximum length of 4 characters. The appearance is such that these 4 characters seem to be delineated by borders which are actually 3 lines displayed above the input field. When I enter the fourth character, a ...

Guidelines for leveraging AngularJS Decorators to deactivate a button within an Html document

Currently, I am utilizing the blur admin theme and exploring the possibility of using decorators to hide a button without directly modifying the HTML. Despite my efforts, I have been unable to successfully conceal the button. Can someone provide guidance o ...

Innovative form creation using Vue.js

My interactive form allows users to input an item, quantity, and cost per item like this: <form @submit.prevent="submit"> <div class="form-group" v-for="(input,k) in inputs" :key="k"> <input ty ...

Trigger the "onChange" event when the input element is modified by JavaScript within a popup window

On my webpage, I have a form element and a popup window (which is opened using window.open). Both the form element and the popup window utilize jQuery. The JavaScript in the popup window has the ability to alter the form element on the main page successf ...

When reference variables are utilized before being parsed, what happens?

I'm a beginner learning Angular and have a question regarding the use of reference variables. Here is an example code snippet: <div class="bg-info text-white p-2"> Selected Product: {{product.value || '(None)'}} </div> <di ...

Modify the background's color and incorporate a pointlight using three.js

Recently, I have been exploring the capabilities of three.js. One interesting challenge I encountered was creating a cube within a wireframe cube. However, I found myself struggling to alter the background color in my project. I believe that incorporating ...

sending information back to the controller with get method (ajax, javascript)

I'm currently facing a challenge where I have an event listener waiting for a button to be pressed. Once the button is pressed, the controller method 'update' is called which then triggers the view method 'input' to fetch data from ...

How to arrange a collection of objects in JavaScript

I am facing a challenge with sorting the array based on the address._id field of each object. Despite attempting to use the lodash orderby function, I have not been able to achieve the desired outcome. [{ rider_ids: '5b7116ea3dead9870b828a1a& ...

Ajax is unable to reach a file located in the directory UP from the application's main folder

Here is the ajax call I am using: <script> jQuery(document).ready(function(){ jQuery('#compare_btn').click(function(event){ event.preventDefault(); var id=jQuery('#compare_btn').attr('name'); alert(id); ...

Creating a CSS animation to mimic the fading in and out effect of the Mac scrollbar when scrolling begins

My journey begins with this: *::-webkit-scrollbar { } *::-webkit-scrollbar-button { } *::-webkit-scrollbar-track { } *::-webkit-scrollbar-track-piece { } *::-webkit-scrollbar-thumb:active { width: 6px; background-color: red; } *::-webkit-scr ...

Is ngSwitch in Angular causing the label element to disappear?

I am using AngularJS to generate form elements dynamically based on an array containing form details such as input type and value. For example, here is the code snippet I have for creating a text input field: <div ng-repeat="input in input_array"> ...

JavaScript and Responsive Design Techniques

I'm struggling to create a responsive page that starts with a mobile-first approach, but I keep running into the same issue. When I have my dropdown menu in the mobile version, it looks good. However, when I try to switch it to the non-mobile version ...

Feeling puzzled by the code snippet for vuejs-templates using webpack-simple?

Just starting out with javascript. Learning Vue.js through example reading. But feeling confused by the code snippet from vuejs-templates/webpack-simple. Specifically line 25 data () { return { msg: 'Welcome to Your Vue.js App' ...

Ways to address a buffered data problem in Websocket Rxjs. When trying to send a message, it is not being received by the server and instead is being stored in a

Currently, I am utilizing Websocket Rxjs within my application. The connection is successfully established with the server, and upon subscribing to it, all data is received in an array format. However, when attempting to send data back to the server, it se ...

Employing a function to concatenate promises

In my coding process, I have come across a situation where I need to fetch content and then save it using two separate functions. Each function performs a different task based on the type of content provided. These functions act as helper functions in my o ...

Establish a pathway based on an item on the list

I need to create a functionality where I can click on a fruit in a list to open a new route displaying the description of that fruit. Can someone guide me on how to set up the route to the 'productDescription.ejs' file? app.js: const express = ...

What is the best way to align text in the vertical center?

Trying to design a promotion layout with an image on the left and text on the right. How can I center the text vertically to appear in the middle of the picture? Attempts using margin and vertical-align have not been successful. Also, why does the text di ...

Encountering an error while deploying a NextJS serverless application using the `npx serverless` command

https://i.sstatic.net/Xb3Hk.png Encountering this issue consistently during the deployment of serverless nextjs, here is my serverless configuration: sprinkle: component: "@sls-next/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data ...