Can we use pure Bootstrap with React.js?

跟風遠走 提交于 2019-11-29 07:09:56

In theory, yes. Since ReactComponent render themselves as html, you can just put the right css classes and there you go. That's totally fine for the css part of bootstrap.

BUT, all the javascript stuff done by the bootstrap library that modify the DOM will be in "conflict" with the virtual DOM of React. One way to avoid that is to never rerender a react component for which its inner html is modified by bootstrap (by setting shouldComponentUpdate() { return false }). Doing this way, you can think of React as just a template library to generate some HTML markup, and letting bootstrap actively modify this markup for you but's it's not what React is made for.

The whole point of React is the ability to see your UI as a function of your state : view = f(state) at any given moment. That's why react-bootstrap reimplements all DOM modifications in a React way.

For sure you can. I will include the bootstrap css as a CDN and go with the normal development.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!