React Native Assignment– 1
Introduction & Setup
Basic Questions
- Install Node.js and verify the version with node -v and npm -v.
- Install the React Native CLI globally and confirm installation.
- Install Expo CLI and run expo –version to check it works.
- Create a new React Native project using React Native CLI.
- Create another project using Expo CLI and compare the initial setup.
- Run the CLI project on an Android Emulator and take a screenshot.
- Run the Expo project in Expo Go App on a physical device.
- Modify App.js to display “Hello React Native” on the screen.
- Use Hot Reloading/Fast Refresh: change text color and confirm instant update.
- Open the android folder in your CLI project and locate the MainActivity.java file.
- Open the ios folder and identify the .xcodeproj file in Xcode.
- Create a src/components folder and add a HelloWorld.js component.
- Import and render HelloWorld inside App.js.
- Use Platform.OS to conditionally render “Android View” or “iOS View”.
- Add a <View> with <Text> styled differently for Android and iOS.
- Create a small list of 5 items in JSX and render it with map().
- Add conditional rendering: if list length = 0, show “No items available”.
- Inspect package.json and add a custom script npm run hello to print “Hello World”.
- Run the app in USB Debugging mode on an Android device.
- Run the app in iOS Simulator using npx react-native run-ios.
Intermediate Questions
- Configure ANDROID_HOME environment variable and verify it with echo $ANDROID_HOME.
- Set up an Android Virtual Device (AVD) in Android Studio.
- Create and run a new iOS simulator from Xcode.
- Add an image to the assets folder and display it using <Image> in React Native.
- Create a component UserCard that takes name and email as props.
- Import UserCard twice with different data and render both.
- Add a button that updates a state variable using useState and display the new value.
- Enable Fast Refresh and test it by editing a component’s background color.
- Add a new file babel.config.js and confirm the app runs without errors.
- Configure a metro.config.js file to include a custom assets folder.
- Modify .gitignore to exclude node_modules and test it with Git.
- Run npm run android and record the startup time.
- Run expo start and scan QR code with Expo Go app.
- Modify App.js to render 3 components: Header, Content, and Footer.
- Pass props from App → Content component and render dynamically.
- Create a stateful counter app with + and – buttons.
- Add conditional JSX to show “Even” or “Odd” based on the counter value.
- Create a scrollable list with ScrollView and 20 items.
- Add TouchableOpacity to simulate button clicks.
- Test your app with both dark and light mode settings on emulator.
Advanced Questions
- Create a cross-platform button: styled differently for iOS and Android using Platform.select().
- Write a custom component PlatformMessage that shows “Welcome iOS” or “Welcome Android” automatically.
- Add a custom hook useDevicePlatform that returns platform details.
- Create a dynamic form with 3 input fields and render them using map().
- Implement conditional rendering: show an image if platform = Android, else show text.
- Create a reusable layout component with slots for Header, Body, and Footer.
- Add a configuration to babel.config.js to use a custom plugin and test it.
- Modify metro.config.js to support SVG imports and render an SVG image.
- Build a list component that dynamically updates when you add/remove items from state.
- Final Hands-on Project:
- Initialize a new React Native app (CLI or Expo)
- Configure Android and iOS emulators
- Set up folder structure (src, assets, components)
- Create 3 components (Header, Content, Footer)
- Add conditional JSX and list rendering
- Configure package.json and metro bundler
- Run on Android emulator + iOS simulator + physical device with Expo