Can React Native app (means same codebase) be turned into mobile web app?

和自甴很熟 提交于 2019-12-02 16:21:20

问题


Whether the same REACT codebase can be shared across mobile web and mobile app?


回答1:


Unfortunately, you cannot. React Native uses a bunch of pre-built components that are really just native iOS components wrapped in Javascript. For example, you could use <div> or <span> in React but in React Native you'd have to use <Text>, images can only be displayed in <Image> components, etc. There are also stricter limitations on what styles, data, or nested components each React Native component can have.

On a side note, trying to do this goes against the React philosphy -> 'Learn once, write anywhere'. You can try taking a look at Ionic if you're interested in something that ports easily over to mobile apps.



来源:https://stackoverflow.com/questions/31740197/can-react-native-app-means-same-codebase-be-turned-into-mobile-web-app

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