I am developing an app with react native and I have a lot of imported modules on different pages. Most of the imported modules are the same on every page for example:
import { Text, View, Image } from 'react-native';
I am using this on many pages. I was wondering if there is a way to store modules like this on one page and call them from what ever page I want.
If you are creating the same type of views in most of your screens then create a separate component and re-use it in all the screens by changing its props as a requirement of view management.
It will help to reduce your code and help you to import fewer modules for most of your code.
For ex. if we have to show a loader on an async task then we have to show an activity indicator in a modal view then we have to import modal, view, activity indicator.
if we create a component let name as an AppLoader we only have to create a loader at a time and import it and show loader by managing a state everywhere in our app code simply.
it will help us to reduce the same code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.