Let’s transform our DesignStudioMobileApp from the default template into a proper design studio interface. I’ll create the folder structure and implement all the features that is requested (https://github.com/MIRA-Designs/DesignStudioMobileApp/issues/4).
Step 1: Create Assets Folder Structure ๐
mkdir -p assets/images
๐ Image Location:
Place our design studio image at: assets/images/featured-design.png
๐ Detailed Code Explanation:
1. Import Statements (Lines 8-19)
import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
View,
TextInput,
Image,
TouchableOpacity,
useColorScheme,
Alert,
} from 'react-native';
What Each Import Does:
React – Core React library for component creation
SafeAreaView – Renders content within safe area (avoids notch/home indicator)
ScrollView – Container that allows scrolling when content exceeds screen
StatusBar – Controls device status bar appearance
StyleSheet – Creates optimized styling objects
Text – Displays text (like <span> in HTML)
View – Basic container (like <div> in HTML)
TextInput – Input field for user text entry
Image – Displays images
TouchableOpacity – Touchable button with opacity feedback
useColorScheme – Hook to detect dark/light mode
Alert – Shows native alert dialogs
2. Component State and Handlers (Lines 21-37)
function App() {
// Hook to detect if device is in dark mode
const isDarkMode = useColorScheme() === 'dark';
// Handler function for search input
const handleSearch = (text: string) => {
console.log('Search query:', text);
// You can add search logic here later
};
// Handler function for category button press
const handleCategoryPress = (category: string) => {
Alert.alert('Category Selected', `You selected: ${category}`);
// You can add navigation logic here later
};
Explanation:
isDarkMode – Boolean that’s true when device is in dark mode
handleSearch – Function called when user types in search bar
Parameter:text: string – what user typed
Action: Logs to console (you can add real search later)
handleCategoryPress – Function called when category button is pressed
Parameter:category: string – which category was pressed
Location:~/react/DesignStudioMobileApp Git Branch:main Project: React Native app with default template
โ Created React Native app with default template
โ Renamed app from “DesignStudioApp” to “DesignStudioMobileApp”
โ Fixed registration errors in iOS AppDelegate
โ Renamed project folder to match app name
โ Clean git history with 2 meaningful commits
โ App running successfully on iOS simulator
Ready for Next Steps:
Our DesignStudioMobileApp is ready for development!
Pending work options:
๐งญ Add navigation between screens (React Navigation)
๐จ Create custom UI components for design studio features
๐ธ Add camera/image functionality for capturing designs
๐พ Set up state management (Redux/Zustand)
๐ฏ Build specific features like project gallery, design tools, etc.
๐ฑ Customize the welcome screen and app styling
๐ฅย Why My MacBook Heatsย Up when do react native development:
Our laptop heating up when running npx react-native run-ios is actually very common in React Native development. Here’s why this happens and how to reduce it:
1. Multiple Heavy Processes Running Simultaneously:
Metro Bundler – JavaScript bundling and hot reloading
Xcode Build System – Compiling iOS native code
iOS Simulator – Running a virtual iPhone with full OS
Node.js processes – Package management and tooling
CocoaPods – iOS dependency management
2. Resource-Intensive Operations:
JavaScript compilation and transformation
iOS native code compilation (Objective-C/Swift)
File watching for hot reload (monitoring thousands of files)
This combination should reduce CPU usage by 30-50% and make your laptop run much cooler! ๐
Quick tip: The heating is normal for React Native development, but these optimizations should make it much more manageable. Monitor Activity Monitor to see the CPU reduction! ๐
Alternative: Could use plain objects, but StyleSheet is better
Lines 22-24:
container: {
flex: 1,
},
container – Style name (can be anything you want)
flex: 1 – Takes up all available space
CSS equivalent:flex: 1 makes the View expand to fill the screen
Purpose: Ensures the app content fills the entire screen
Line 28: Export Statement ๐ค
export default App;
export default – Makes the App component available to other files
Purpose: Allows index.js to import and register this component
Required: Without this, React Native can’t find your app component
๐ How It All Works Together:
Flow of Execution:
Import dependencies โ Get required React Native components
Define App component โ Create the main component function
Detect color scheme โ Check if user prefers dark/light mode
Render UI โ Return JSX that describes the screen
Apply styles โ Style the container to fill screen
Export component โ Make it available to React Native
Visual Structure:
๐ฑ Phone Screen
โโโ ๐ StatusBar (adapts to dark/light mode)
โโโ ๐ฆ View (container that fills screen)
โโโ ๐ NewAppScreen (welcome screen with React Native content)
Key Concepts:
Concept
Explanation
Example
JSX
HTML-like syntax in JavaScript
<View> instead of <div>
Components
Reusable UI pieces
<StatusBar>, <View>
Props
Data passed to components
barStyle="dark-content"
Hooks
Functions that add React features
useColorScheme()
Styles
CSS-like styling for React Native
StyleSheet.create()
React Native vs Web Differences:
Web (HTML/CSS)
React Native
Purpose
<div>
<View>
Container
CSS files
StyleSheet
Styling
Media queries
useColorScheme()
Responsive design
Manual status bar
<StatusBar>
System UI control
๐ฏ What You’re Seeing on Screen:
When you run this app, you see:
โ React Native logo
โ “Welcome to React Native” text
โ Links to documentation
โ Step-by-step instructions
โ Status bar that adapts to your phone’s theme
This is the default template – a starting point for building our DesignStudioMobileApp! ๐
โ๏ธ Functional vs Class Components in React
Type
Introduced In
Simpler Syntax
Supports Hooks
Uses this?
Functional Component
React since beginning, became more powerful in React 16.8
โ Yes
โ Yes
โ No
Class Component
React 0.13+
โ Verbose
โ Old pattern
โ Yes
๐งฉ 1. Functional Component (Modern)
โ What is it?
A JavaScript function that returns JSX. As of React 16.8, functional components can manage state and side effects using Hooks (useState, useEffect, etc.).
โ ๏ธ More boilerplate, needs this, not as concise.
๐ค Why Two Types?
๐งช Historical Reason:
Before React 16.8, only class components could have state or lifecycle methods.
Functional components were stateless-only.
๐ก Then came Hooks (React 16.8):
Gave functional components full power: state, side effects, refs, context.
Made class components mostly obsolete for new code.
๐ง Which One Should You Use?
โ Use Functional Components unless:
You’re working with legacy code
You’re learning how React evolved
A library forces you into class-style APIs (rare now)
โ TL;DR
Feature
Functional Component
Class Component
Syntax
Simple function
Class with extends Component
State support
โ Yes (via Hooks)
โ Yes
Lifecycle methods
โ Yes (via Hooks like useEffect)
โ Yes (componentDidMount, etc)
this keyword
โ No
โ Yes
Modern React choice
โญ Preferred
Deprecated for new apps
Absolutely! Letโs go over the most important React Hooks that turned functional components into full-featured building blocks, just like class components (and even more powerful!).
โ๏ธ React Hooks โ Power Tools for Functional Components
Introduced in React 16.8, Hooks let you:
Use state, side effects, context, refs, etc.
Without writing a class component
๐งฐ Essential React Hooks (with Examples)
1๏ธโฃ useState โ Manage Local Component State ๐ง
๐ When to Use:
To store and update component-level state (like a counter, input field value, toggle, etc.)
The guide is for creating a React Native app for our design studio web application made with Ruby On Rails 8. Let me start by explaining the fundamentals and then walk you through the entire setup process.
What is React Native? ๐ค
React Native is a framework developed by Facebook (now Meta) that allows you to build mobile applications using JavaScript and React. It enables you to write code once and deploy it on both iOS and Android platforms.
Why Use React Native? ๐ฏ
Key Benefits:
Cross-Platform Development: Write once, run on both iOS and Android
Code Reusability: Share up to 90% of code between platforms
Native Performance: Uses native components, not webviews
Hot Reloading: See changes instantly during development
Large Community: Extensive libraries and community support
Cost-Effective: Faster development with smaller teams
Facebook Backing: Strong ecosystem and continuous updates
React Native vs React: Key Differences ๐
Aspect
React
React Native
Target Platform
Web browsers
Mobile devices (iOS/Android)
DOM
Virtual DOM
Native components
Styling
CSS
StyleSheet API (CSS-like)
Components
HTML elements (<div>, <p>, etc.)
Native components (<View>, <Text>, etc.)
Navigation
React Router
React Navigation
Deployment
Web servers
App stores
Development
Browser dev tools
Mobile simulators/devices
Setting Up Your React Native Development Environment ๐ ๏ธ
Let me guide you through creating your React Native app step by step:
Step 1: Install Prerequisites
First, let’s check your current setup and install the necessary tools: Ran tool
We’ll need to install several tools. Let me guide you through each one:
1. Node.js & npm/yarn
# Check if Node.js is installed
node --version
npm --version
# If not installed, download from https://nodejs.org/
# Or install via Homebrew (recommended for macOS):
brew install node
2. React Native CLI
npm install -g @react-native-community/cli
3. For iOS Development (macOS only):
# Install Xcode from Mac App Store
# Install CocoaPods
# Homebrew
brew install cocoapods
# Later
# Update with Homebrew
brew upgrade cocoapods
# OR use ruby gem
sudo gem install cocoapods
4. For Android Development:
Install Android Studio
Set up Android SDK
Configure environment variables
Step 2: Create Your React Native App
Let’s navigate to our react folder and create the app. Let’s create our React Native app for the design studio.
Run these commands in our terminal:
# Navigate to your react directory
cd ~/react
# Create a new React Native app
npx react-native init DesignStudioApp
# Navigate to the new app directory
cd DesignStudioApp
๐ Our DesignStudioApp has been created successfully!
What Happened
The React Native CLI successfully:
โ Downloaded the template
โ Copied template files
โ Processed the template
โ Installed dependencies
โ Initialized Git repository
โ CocoaPods is Already Installed!
CocoaPods version 1.16.2_1 is properly installed via Homebrew in our system.
CocoaPods manages dependencies for your Xcode projects.
You specify the dependencies for your project in a simple text file: your Podfile. CocoaPods recursively resolves dependencies between libraries, fetches source code for all dependencies, and creates and maintains an Xcode workspace to build your project. The latest released Xcode versions and the prior version are supported.
โ Complete Installation: All necessary files are present
# Let's Verify CocoaPods is Working
pod --version
1.16.2
Now Let’s Try Installing iOS Dependencies ๐ฑ
Since CocoaPods is working, let’s try to install the iOS dependencies for our DesignStudioApp:
cd DesignStudioApp/ios && pod install
....
[Hermes] Using release tarball from URL: https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.80.1/react-native-artifacts-0.80.1-hermes-ios-debug.tar.gz
Step 3: Understanding the Project Structure ๐
After creating the app, you’ll see this structure:
DesignStudioApp/
โโโ android/ # Android-specific code
โโโ ios/ # iOS-specific code
โโโ node_modules/ # Dependencies
โโโ src/ # Your app source code (you'll create this)
โโโ App.tsx # Main app component
โโโ index.js # Entry point
โโโ package.json # Dependencies and scripts
โโโ metro.config.js # Metro bundler configuration
โโโ ...
Step 4: Key Files Explained ๐
App.tsx – Main component (like App.js in React web) index.js – Entry point that registers your app package.json – Dependencies and scripts android/ & ios/ – Platform-specific native code
Step 5: Running Your App (No XCode installed) ๐
For iOS Simulator:
# Make sure you're in the DesignStudioApp directory
npx react-native run-ios
Install Xcode: Xcode Component Selection for React Native Development ๐ ๏ธ
For React Native development, you should select BOTH:
โ Required Components:
macOS15.5 (built-in) – โ Select this
iOS 18.5 – โ Select this (Essential for React Native)
# Install iOS Dependencies Again
cd DesignStudioApp && cd ios && pod install
๐ CocoaPods Installation Complete!
All iOS dependencies have been successfully installed!
What Just Happened โ
โ 74 dependencies installed from Podfile
โ 73 total pods installed successfully
โ React Native modules all configured
โ Hermes engine installed (JavaScript engine)
โ Xcode workspace created
Hermes is an open-source JavaScript engine optimized for React Native. For many apps, using Hermes will result in improved start-up time, decreased memory usage, and smaller app size when compared to JavaScriptCore. Hermes is used by default by React Native and no additional configuration is required to enable it.
Important Note ๐
The system created a .xcworkspace file – this is what you’ll use instead of .xcodeproj from now on.
# Step 5: Now Let's Run Your App on iOS!
โ npx react-native run-ios
info Found Xcode workspace "DesignStudioApp.xcworkspace"
info No booted devices or simulators found. Launching first available simulator...
info Launching iPhone 16 Pro (iOS 18.5)
info Building (using "xcodebuild -workspace DesignStudioApp.xcworkspace -configuration Debug -scheme DesignStudioApp -destination id=XXXX-XXXXX-XXXX-XXXX
Step 1: Install iOS Dependencies ๐ฆ
Open your terminal and run these commands:
# Navigate to your app directory
cd ~/react/DesignStudioApp
# Install iOS dependencies
cd ios && pod install && cd ..
This will install all the necessary iOS libraries and dependencies.
Step 2: Run the iOS App ๐ฑ
Option A: Use React Native CLI (Recommended)
Open a new terminal window (keep Metro running in the first one) and run:
cd ~/react/DesignStudioApp
npx react-native run-ios
Option B: Use Xcode Directly
# Open the iOS project in Xcode
cd ~/react/DesignStudioApp
xed ios/DesignStudioApp.xcworkspace
Then press the “Run” button (โถ๏ธ) in Xcode.
What Should Happen ๐ฏ
iOS Simulator opens – A virtual iPhone will appear
App builds – You’ll see build progress in terminal
App launches – Your DesignStudioApp will open in the simulator
Metro connects – The app connects to the development server
Expected Output ๐ฑ
You should see the default React Native welcome screen with:
React Native logo
“Welcome to React Native” message
Various getting started links
Debug information
Common Issues & Solutions ๐ง
Issue 1: “No iOS Simulator Available”
# List available simulators
xcrun simctl list devices
# If no simulators, create one in Xcode:
# Xcode > Window > Devices and Simulators > Create Simulator
Issue 2: “Build Failed”
# Clean and rebuild
cd ~/react/DesignStudioApp
npx react-native run-ios --clean
Issue 3: “Metro not responding” – not used metro
# Reset Metro cache
npx react-native start --reset-cache
Quick Commands Summary ๐
# Terminal 1: Start Metro
cd ~/react/DesignStudioApp
npx react-native start
# Terminal 2: Run iOS app
cd ~/react/DesignStudioApp
npx react-native run-ios
What You’ll See ๐
Your app should display:
React Native welcome screen
“Welcome to React Native” text
Various learning resources
Debug information
Testing Your App ๐งช
Once running, you can:
โ+D – Open developer menu
โ+R – Reload the app
โ+T – Open new simulator
Shake gesture – Open dev menu on device
Next Steps After Success ๐
Once your app is running:
Edit App.tsx – Make changes to see hot reload
Add navigation – React Navigation
Add UI components – For your design studio
Add features – Camera, image picker, etc.
Run These Commands Now! ๐ป
Open your terminal and execute:
cd ~/react/DesignStudioApp
cd ios && pod install && cd ..
npx react-native run-ios
This should launch your DesignStudioApp in the iOS simulator! ๐
NPX is a package runner tool that comes with npm (Node Package Manager). It was introduced in npm version 5.2.0 and is now a standard part of the npm ecosystem.
NPX Full Name:
NPX = Node Package eXecute
It’s a command-line tool for executing npm packages
How NPX Works ๐ง
Basic Concept:
Instead of installing packages globally, npx allows you to:
Run packages directly without installing them permanently
# Old way - install globally first
npm install -g create-react-app
create-react-app my-app
# NPX way - run directly
npx create-react-app my-app
2. Always Latest Version
# NPX ensures you get the latest version
npx create-react-app my-app
# vs global install might be outdated
npm install -g create-react-app # Might be old version
create-react-app my-app
# Force download (ignore local/global)
npx --ignore-existing create-react-app my-app
# Use specific version
npx create-react-app@4.0.0 my-app
# Check what would be executed
npx --version create-react-app
# Run from specific package
npx -p typescript tsc --init
# Start Metro bundler
npx react-native start
# Run on iOS
npx react-native run-ios
# Run on Android
npx react-native run-android
Other Useful Commands:
# Check React Native version
npx react-native --version
# Upgrade React Native
npx react-native upgrade
# Doctor (check environment)
npx react-native doctor
Benefits Summary ๐
For Developers:
โ Cleaner system – No global package clutter
โ Always updated – Latest versions automatically
โ Faster setup – No pre-installation needed
โ Less conflicts – No version conflicts
For Projects:
โ Consistent environments – Everyone uses same versions
โ Easier setup – New team members can start quickly
โ Better CI/CD – Consistent builds
Pro Tips ๐ก
Use NPX for project creation – Always use npx for scaffolding tools
Check before installing globally – Ask yourself: “Do I need this globally?”
Use specific versions when needed – npx package@version
Great for CI/CD – Ensures consistent tool versions
NPX is essentially a way to “try before you buy” – run packages without the commitment of installing them permanently! It’s become an essential tool in modern JavaScript development. ๐
Let’s see in Part 2.. Happy React Native Development ๐