JustLogin JustLogin - 1 year ago 124
React JSX Question

Cannot create custom style with React and Bootstrap

I'm using

NPM package to make my
components look properly. I need to customize some of them, so I'm following the official React-Bootstrap documentation, but the code throws the error
index.jsx:5 Uncaught TypeError: Cannot read property 'addStyle' of undefined

This is my custom
component code:

import React from "react";
import Button from 'react-bootstrap/lib/Button';
import bootstrapUtils from 'react-bootstrap/lib/utils/bootstrapUtils';

bootstrapUtils.addStyle(Button, 'custom');

export default class MediaItemButton extends React.Component {
render() {

return (
<style type="text/css">{`
.btn-custom {
background-color: purple;
color: white;
<Button bsStyle="primary">Custom</Button>

Answer Source

Change to this:

import { bootstrapUtils } from 'react-bootstrap/lib/utils';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download