Is npm react-bootstrap automatically scoped to a component? - javascript

I am using react with react-bootstrap. My question now is, are react-bootstrap components automatically scoped to the component that you are using it in? Or am I asking a totally wrong question here? Because as I am aware that those bootstrap components are native react components, I am normally importing them like this:
import {Navbar, Nav, NavItem} from 'react-bootstrap';
but would it also be possible, to customize them or create own styles in a .css file (and overwrite other react-boostrap component styles) and import them into another component? I know they would not be react-bootstrap components then anymore, but would this be possible? E.g I could customize a button react-bootstrap component class in some .css file and import it in my module, would it overwrite native react-bootstrap classes?

Related

Remove any external stylesheet inside react app

The image will best describe this:
code sandbox:https://codesandbox.io/s/annoying-stylesheet-2gpejc?file=/public/index.html
You can see some styles were removed (for 'code' element for example), but not all the styles(MUI TextInput Component)
I'm writing React app inside non react app and their styles interfere with my React app styles.
How do I overwrite bootstrap-enterprise.css stylesheet only for the region of my React app without overriding the style rest for the rest of the page (The top app bar is theirs)
.App {
all: revert;
}
worked initially, but then I tried it my real usecase (overrding Mui Textfield styling component) and it didn't.

Overriding Bootstrap with custom css

I use npm I bootstrap in reactjs project , but I want to modify some of the elements, so I wrote my own custom.css. However it doesn't make any changes (only when I put !important, but the file is so large so it's not a good option).
import these in index.js
import "bootstrap/dist/js/bootstrap.bundle.min";
import "bootstrap/dist/css/bootstrap.css"
and in a single component, I have use bootstrap classes but It affects my all components and also inline custom CSS Style

Material UI Icons not rendering correctly

I'm sorry to ask this again but I cannot for the life of me find out what is going on. I am moving my React app inside an angular app and have got everything working except for the material-ui/icons They are there, they just do not look as they should!
I'm using the most current packages I have the link to the styles in my index.html file and I believe I'm using the Icons correctly.
import { Close } from '#material-ui/icons'
<Close />
This is what they look like on my app.
Bad Icons Image
I don't have any console errors pertaining to material-ui or the Icons.
It should be:
import Close from '#material-ui/icons/Close'
Try this too:
import Icon from '#material-ui/core/Icon';
<Icon>close</Icon>
If your environment doesn't support tree-shaking, the recommended way to import the icons is the following:
import Close from '#material-ui/icons/Close';
If your environment support tree-shaking you can also import the icons this way:
import { Close } from '#material-ui/icons';
Importing named exports in this way will result in the code for every icon being included in your project, so is not recommended unless you configure tree-shaking. It may also impact Hot Module Reload performance if you enable it.
To enable tree shaking click me

Why does importing Buefy to my Vuejs project makes <h1> tag and some Bootstrap element display the wrong style?

I'm using Bootstrap 4 and Buefy in my webpack-simple Vue.js project. When I import Buefy just like in the Docs, my tag does not enlarge the text and the nav-bar in Bootstrap 4 displaying the wrong width.
My main.js file looks like this
import Vue from 'vue';
import "bootstrap/dist/css/bootstrap.min.css";
import 'buefy/dist/buefy.css';
import Buefy from 'buefy';
Vue.use(Buefy);
What it should be when I remove the import Buefy:
But importing Buefy to my main.js lead to this problem:
Buefy is based on the underlying Bulma CSS framework which conflict with Bootstrap at some points as they implies global styles and class names that may be the same.
You can try to use LESS with Bootstrap to avoid conflicts but I feel this is overcomplicating and you should just stay with one or the other, known that there is a Bootstrap-Vue port and that Bulma (Buefy also then) do exactly the same things as you can do with Bootstrap

How to extend a react component from a library

I want to extend the FormControl component from react-bootstrap. Importantly though, I want my extended component to replace the react-bootstrap component, so that importing from the react-bootstrap package actually imports my extended component.
Mostly I need to change the render method to include an absolutely-positioned counter for input[type=text] and textarea nodes, by looking at their inputRef prop.
What is the best way to do this?
Reacts core idea is composability over inheritance . So you wrap you component around the bootstrap component and use your component everywhere .
For extending, this should do:
import MyComponent from 'react-bootstrap'
class NewComponent extends MyComponent {
}
Pretty sure you can't overwrite an import from a package like you want though because it makes no sense to do so. Just import from the new component instead.
Why exactly do you want to overwrite the existing instead of just providing a wrapping component that inherits it?

Categories

Resources