Below is my Greeter.jsx file:
import React, {Component} from 'react';
import cssModules from 'react-css-modules';
import {Button} from 'react-bootstrap';
import styles from './Greeter.css';
const option = {
'allowMultiple': true
};
class Greeter extends Component{
render() {
return (
<div styleName='root root-child'>
<h1>Welcome to React Devops.</h1>
<p styleName="para">This is an amazing para.</p>
<p>Hot module reload.</p>
<Button bsStyle="primary">Test</Button>
</div>
);
}
}
export default cssModules(Greeter, styles, option);
Below is my main.js file:
import React from 'react';
import {render} from 'react-dom';
import Greeter from './Greeter';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/css/bootstrap-theme.min.css';
import './main.css';
render(<Greeter />, document.getElementById('root'));
I use postcss-modules and react-css-modules to isolate selectors within components due to which, when the file loads, the class name becomes something like _3lmHzYQ1tO8xPJFY8ewQax.
Example:
<div class="_3lmHzYQ1tO8xPJFY8ewQax _32vj3squi8uWPfEu4ZzyBZ" data-reactid=".0"></div>
Below is how react-bootstrap would give me the output:
<button class="btn btn-primary"></button>
which has not been isolated as I use bsStyle (react-bootstrap) rather than styleName(react-css-modules) and hence I cannot apply the bootstrap css style to the element.
Is there a way through which I can use react-bootstrap by isolating its class to match the output that postcss-modules generate?
Thanks in anticipation.