Can React Native app (means same codebase) be turn

2020-05-03 18:57发布

问题:

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.