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.