我们可以在React.js中使用纯Bootstrap吗? [英] Can we use pure Bootstrap with React.js?

查看:257
本文介绍了我们可以在React.js中使用纯Bootstrap吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将网站从PSD原型转换为HTML / CSS / Bootstrap,然后转向JavaScript开发并使用React.js和一些JavaScript编码。

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.

是否可以在不使用React-Bootstrap的情况下使用带有React.js的纯Bootstrap?

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

也可以将HTML / CSS Freelancer作为模型进行React-Bootstrap然后找一个JavaScript开发人员来做React.js和JS开发等高级工作?

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?

我想使用相同的代码库为Electron和Hybrid App开发桌面应用程序尽可能。

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

推荐答案

理论上,是的。由于ReactComponent将自己渲染为html,因此您可以将正确的css类放在那里。这对于bootstrap的css部分来说完全没问题。

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.

但是,修改DOM的bootstrap库完成的所有javascript内容都将在与React的虚拟DOM冲突。
避免这种情况的一种方法是永远不要重新渲染其内部html由bootstrap修改的react组件(通过设置 shouldComponentUpdate(){return false} )。
这样做,你可以把React想象成一个模板库来生成一些HTML标记,然后让bootstrap主动修改这个标记,但不是React的用途。

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.

React的重点是能够将UI视为您的状态的函数: view = f(state)在任何特定时刻。
这就是为什么 react-bootstrap 以React方式重新实现所有DOM修改。

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.

这篇关于我们可以在React.js中使用纯Bootstrap吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆