Skip to main content
React Native Introduction
CHAPTER 04 Beginner

Understanding React Fundamentals

Updated: May 16, 2026
7 min read

# CHAPTER 4

Understanding React Fundamentals

1. Introduction

React Native is exactly what its name implies: it is React applied to Native devices. If you do not understand how React thinks, you will not be able to build mobile apps. React forces developers to stop thinking imperatively ("Do this, then do that") and start thinking declaratively ("This is what the UI should look like based on current data"). In this chapter, we will master Understanding React Fundamentals. We will explore the core pillars of the React philosophy: JSX syntax, building LEGO-like Components, passing data via Props, and managing dynamic changes using State.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Explain the concept of a Declarative UI.
  • Understand the syntax and rules of JSX.
  • Define what a Component is and how to build one.
  • Understand how to pass data down the tree using Props.
  • Understand the concept of State and how it triggers UI re-renders.

3. Imperative vs Declarative UI

  • Imperative (The Old Way - Vanilla JS/jQuery): You give step-by-step instructions. *"Find the button with ID 'submit'. Add an event listener. When clicked, change the background color of the div with ID 'box' to red."* This results in spaghetti code.
  • Declarative (The React Way): You declare the rules. *"If the state 'isClicked' is true, the box is red. If false, it is blue."* When the button is clicked, you just change isClicked to true. React automatically figures out how to redraw the box.

4. Components (The Building Blocks)

A React application is just a giant tree of Components. A Component is a reusable, self-contained piece of UI. Think of them like custom HTML tags or LEGO bricks. You build small bricks (a Button, an AvatarImage), snap them together to build a medium brick (a ProfileCard), and snap those together to build a large brick (the HomeScreen).

In modern React, a Component is simply a JavaScript function that returns UI!

javascript
12345
// A simple React Native Component
function WelcomeMessage() {
  // It must return UI elements!
  return <Text>Welcome to my App!</Text>; 
}

5. JSX (JavaScript XML)

Look at the code above. We are returning HTML-like tags directly inside a JavaScript function! This magical syntax is called JSX. JSX is a syntax extension that allows you to write UI visually, while retaining the full computational power of JavaScript.

Rules of JSX:

  1. 1. You can inject JavaScript variables directly into the UI using curly braces {}.
  1. 2. A component must return a single parent element. (You cannot return two sibling Text tags without wrapping them in a parent <View>).

javascript
12345678910
function UserProfile() {
  const userName = "Alice"; // JavaScript logic
  
  return (
    <View> {/* The single parent wrapper */}
      <Text>Profile Page</Text>
      <Text>Name: {userName}</Text> {/* Injecting JS into UI! */}
    </View>
  );
}

6. Props (Properties)

Props are how components talk to each other. They allow you to pass data from a Parent component down to a Child component. Props are *read-only*. A child cannot modify the props it receives.
javascript
1234567891011121314
// The CHILD component (Receives props)
function GreetingCard(props) {
  return <Text>Hello, {props.name}!</Text>;
}

// The PARENT component (Passes props)
function App() {
  return (
    <View>
      <GreetingCard name="Alice" /> {/* Passing 'Alice' */}
      <GreetingCard name="Bob" />   {/* Reusing the component! */}
    </View>
  );
}

7. State (Dynamic Data)

Props are static data passed from above. State is dynamic data managed *inside* the component itself. If a component has data that changes over time (like a score counter or text typed into an input), that data must be stored in State. The Golden Rule of React: When State changes, React automatically re-renders (redraws) the component to reflect the new data! *(We will cover exactly how to code this using the useState hook in Chapter 8).*

8. Visual Learning: The Component Tree

txt
123456
                      [ App Component ] (State: isLoggedIn = true)
                             |
         +-------------------+-------------------+
         |                                       |
[ Header Component ]                   [ Profile Component ]
(Receives prop: title="Home")          (Receives prop: userName="Alice")

9. Common Mistakes

  • Modifying Props: Beginners often try to do props.name = "Steve"; inside a child component. This will crash the app. Props flow strictly downward and are immutable (read-only). If a child needs to change data, it must use State, or the Parent must pass down a function via props that the child can trigger!

10. Best Practices

  • Component Naming: In React, custom components MUST start with a Capital Letter (e.g., <MyCustomButton />). If you start it with a lowercase letter (e.g., <myCustomButton />), React will assume you are trying to use a built-in native tag and it will fail to render.

11. Practice Exercises

  1. 1. What magical syntax allows you to write HTML-like tags directly inside JavaScript functions?
  1. 2. If Component A is nested inside Component B, what mechanism should Component B use to send a string of text down to Component A?

12. MCQs with Answers

Question 1

Which of the following statements correctly describes the difference between State and Props in React?

Question 2

Why is a React Native app referred to as having a "Declarative UI"?

13. Interview Questions

  • Q: Explain the concept of JSX. How does the Babel compiler transform JSX code behind the scenes before it runs on a device?
  • Q: Contrast Declarative UI (React) with Imperative UI (Vanilla DOM manipulation or classic Android XML/Java). Provide an example of how each handles updating a text label on a button click.
  • Q: What is the "Unidirectional Data Flow" (One-Way Data Flow) principle in React regarding parent and child components?

14. FAQs

Q: Do I need to learn React for the web before learning React Native? A: No! While helpful, it is not required. The core concepts of React (Components, Props, State) are identical whether you are building for the web or mobile. You can absolutely learn React principles directly through React Native.

15. Summary

In Chapter 4, we unlearned traditional imperative programming and embraced the React Philosophy. We learned to construct our interfaces declaratively, describing what the UI should look like based on current data. We explored the architectural pillars of React: writing visual code using JSX, compartmentalizing UI into reusable Components, passing read-only data downwards using Props, and managing dynamic, UI-refreshing data using State.

16. Next Chapter Recommendation

We know the theory, the setup, and the syntax. It is finally time to write our first line of mobile code. Proceed to Chapter 5: Creating Your First React Native App.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·