|
|
|
|
|
by Groxx
2333 days ago
|
|
React's behavioral features are relatively difficult, I'll grant, but it's entirely possible to use it as a relatively dumb "render X efficiently for me" target. If you're using hooks heavily, you're deeply entangling your code with the framework - that's your choice, but yeah, it comes with consequences as well as benefits. Android lifecycles are probably the main target of my comment tbh. They're abysmally complex and make any kind of state management incredibly error-prone. As a tradeoff for that complexity and losing a lot of control, if (and only if) you go all-in on them, you get decent state reviving after process death, which can do really slick things like "app crashed" -> it just appears to go back one screen. Instead, you can write your app as e.g. an in-memory singleton somewhere. You can even do that in a different thread if you want, leaving your UI impossibly smooth (at increased risk of "tap x" -> "nothing happens"). Design your own lifecycle that makes sense for your app (which probably looks very little like the Android lifecycle, especially when you throw in fragments...) and trigger/wait on the external world of the Android framework as needed. Odds are pretty good that you'll take multiple things from Android and combine them into one in yours, and potentially vise versa (e.g. multiple actions from your app become view updates in a single activity, rather than multiple activities. or do everything in one activity, it's often far better performance anyway, and much easier to control in fine-grained ways. importantly, your core logic doesn't care, unlike if you put that logic in the activities). |
|