How I separate the logic and my view in React Native

Initial view
view with handle press
HomeView with a single responsibility
useHome Hook
Exporting your component to be used by the app
withHook function


There isn’t the best way or best pattern for all teams and projects, there are a lot of ways to create your components. And with this way you can separate your logic and view of course, if your app is small maybe it’s not needed
Once the app grows you will need to create tests and add more logic to your components and for this case maybe using the single responsibility your code will still be small and maintainable.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store