Can we use pure Bootstrap with React.js?

这一生的挚爱 提交于 2019-11-28 00:56:57

问题


I would like to convert websites from PSD prototype to HTML/CSS/Bootstrap and then move on to JavaScript development and using React.js and some JavaScript coding.

Is it possible to use pure Bootstrap with React.js without using React-Bootstrap?

Also is it possible HTML/CSS Freelancer to do React-Bootstrap as a mockup only and then find a JavaScript developer to do the advance work like React.js and JS development?

I would like to develop app for Desktop using Electron and Hybrid App using same code base as possible.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/38015494/can-we-use-pure-bootstrap-with-react-js

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