我可以在react-native中使用reactJS库吗? [英] Can I use reactJS library in react-native?

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

问题描述

嗯,这可能是一个愚蠢的问题,但我想澄清原因.React-Native导入了nodeJS库,因此,尽管reactJS包含纯HTML组件,但我认为也可以使用reactJS库.

Well, this might be a silly question but I want to clarify the reason. React-Native imports nodeJS libraries, so I think it is possible to use reactJS library as well though reactJS includes pure html components.

React Native是否可以识别包括HTML的reactJS组件?

Can react native recognize reactJS components including html?

推荐答案

react 库实际上没有与浏览器DOM HTML相关的任何内容.与它相关的所有内容都被分离成 react-dom 包.React Native不会也不能使用此库,因为您在React Native应用程序下没有DOM.但是,如果安装了必要的转换库,则可以在浏览器中使用为移动应用程序编写的大多数代码/功能.这是可能的,因为react native定义了一些可以移植到几乎任何平台的原始组件.如果您仍然只想使用HTML来在react native中进行渲染,则可以使用 WebView .

react library actually does not have anything related to Browser DOM HTML. Anything related to it separated into react-dom package. React Native does not and cannot use this library, because you don't have DOM underneath a react native application. However you can use most of the code/functionality you wrote for your mobile app in the browser, if you install necessary transpiling library. This is possible because react native defines some primitive components that can be ported to almost any platform. If you still want to use just HTML to render inside react native, you may use WebView for it.

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

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