preface

Since the beginning of 2017, it has been a year since the react-Native project was started. What we do is an IM software, embedded in the engineering of a mobile gaming platform. The reason why react-Native (RN for short) framework was used to reconstruct it is because all games in the game hall are hot updates. RN is a good choice in order to enable real-time updates of the IM software and reduce the number of IPA upgrades.

After nearly a year of pre-research by a colleague, we started the project reconstruction in 2017. In the rush to hot update and Write once, Run everywhere, then embarked on RN pit filling journey.

From the ES6, CSS layout, story began

I’ve been working on iOS development, working in OC, and I was new to ES6. The language style is completely different from the C language style. RN uses a tabbed interface layout, called CSS-Layout, which is basically the same as CSS. Although it is the first time to use this way of layout interface, with familiar feel very convenient, less code, very direct. For chat, we use the Redux architecture, which is a JavaScript state machine. Refer to www.redux.org.cn/index.html

The advantage of RN

  • Debugging convenience after ipA is installed, there is no need to compile frequently, just need to reload, download js code from the cloud server can present the effect of the changed code. RN also supports hotReload, which is very convenient when debugging the interface. After modifying the code and saving it, the interface automatically changes. This is really cool when debugging, but sometimes it is a little slow and needs to be reload. Chrome online debugging is also pretty good, you can break point, see the log. It’s not as seamless as Xcode or Android Studio, but it’s a great debugging tool for scripting languages.

  • CSS – Layout for front-end programmers, reduce a lot of learning costs, but also greatly reduce the amount of code. But for iOS or Android developers, it’s a bit of a mind-shift to get started.

  • Most of the cross-platform code, you only need to write one set, android and iOS can run, game logic and data. Part of the interface has some platform differentiation, after all, it’s packaged from React. When I first started learning iOS, I imagined that there would be a cross-platform form of development, but a few years later there was. In theory, cross-platform can reduce development costs and reduce the number of developers, but in practice it doesn’t work that way.

  • Hot updates this is probably the main reason most companies choose to use RN. Frequent app updates can be annoying to users, and Apple’s approval process can be troublesome. RN is now used by many large apps. After all, it is a nightmare to pass app approval every time there are many business iterations.

  • Having a good dad with Facebook to back him up will be great.

RN’s imperfections

If I may joke, there are so many things that are not perfect, and compared to the native development experience, it is a far cry. The latest version of RN is 0.46, and we’re working with 0.42, not 1.0 yet. Without subjective feelings, here are some imperfect points:

  • The development experience is mediocre. Although JS syntax is very flexible, but after all is a scripting language, debugging is still not convenient, easy to check the error. We use the better performance of vscode editor, this feel all kinds of jump is very inconvenient, always have to global search, may be xcode used to it. Scripting language writing will slowly get used to it.

  • The documentation is very rough, just a brief introduction to the usage and the properties of each control, very little detail description. When you have a difficult problem or step in a hole, the answer is almost impossible to find.

  • The two platforms are not completely unified yet and a lot of the controls are either iOS specific or Android specific. There are also some of the same controls that behave differently on different platforms.

  • Control is not perfect this actually quite a lot of, the most basic ListView, function loss, pit a lot of. Text does not support rich Text, animations, gestures, scrollViews, etc. I can’t list them all. As chat software, rich text function must be implemented, for emoji and text mixed display. I was forced to create my own implementation, which is still a bit buggy. The concrete implementation scheme reference blog.csdn.net/gang5440439…

  • Upgrading RN requires a lot of work. We recently upgraded RN from 0.42 to 0.50. It’s really a hassle. The PropTyps have been moved out of React, so references will have to be changed, and all files will be checked one by one. Previously used third-party libraries, including those related to PropTyps, have had to be updated. In many previous interface layouts, other controls were placed on the image, and errors were reported after upgrading, and then adjustments were made.

  • It takes a lot of manpower and time to polish cross-platform app to make a good app. In fact, it does not reduce the development cost. In the past, there were three android and iOS employees, and each iteration was carried out in an orderly manner. However, if YOU change RN, all 6 people will play, so it’s exhausting, slow iteration and lots of bugs.

conclusion

FaceBook also wants to bring developers a cross-platform, dynamically updated Javascript framework with the tagline: Learn Once, Write Anywhere: Build Mobile apps with React. I think it’s a great dream.

When it was first released in 2015, it was filled with anticipation and controversy. So far, RN has been improving. There’s been a lot of panic about apple sending out warning emails, but RN is safe as far as I’m concerned. Apple’s audit policy allows dynamically loaded code to run on JavascriptCore, without using other people’s private methods. And despite Apple’s arrogance, it will have to weigh the opinions of large companies that now use RN.

RN is certainly not mature and stable at the moment, so developers and decision makers who want to go into the pit have to weigh a lot before going into the pit. Although as a technology developer, we should have a keen sense of new technology and the ability to learn quickly, we should be cautious about the technical update of the project according to the actual situation. User experience and development costs are the two most important tradeoffs.

After all, whether it’s React-Native,JSPatch, or anyone else updating technology, it’s backwards in terms of the home experience and development experience.

Who is RN for

  • Hot update is urgently needed
  • Willing to commit people and money to RN

Other common applications that don’t need hot updates so badly should use native development, which is much more mature and stable than RN.

The original address: https://blog.csdn.net/gang544043963/article/details/77507940, reprint please indicate the original