State and Props in React Native


State and Props in React Native Interview with follow-up questions

1. What are props in React Native?

Props (properties) are the read-only inputs a parent passes down to a child component to configure it. The child receives them as its function argument and must treat them as immutable — it renders based on props but never mutates them.

function Greeting({ name }) {
  return Hello, {name}!;
}

// parent

Points interviewers listen for:

  • Data flows one way (parent → child). To send data back up, the parent passes a callback prop the child calls (e.g. onPress, onChange).
  • Props can be any value — strings, numbers, objects, arrays, functions, even other components — and children is the special prop for nested content.
  • Props vs state: props are owned by the parent and read-only; state is owned and updated by the component itself. When props change, the child re-renders.
  • Good practice: destructure props, set default values, and type them (TypeScript) — type-safe props are expected in modern RN code.
↑ Back to top

Follow-up 1

How are props used in React Native?

Props are used by passing them as attributes to a child component in the parent component's JSX. The child component can then access the props using the props object.

Follow-up 2

Can you modify props inside a component?

No, props are read-only and cannot be modified inside a component. If you need to modify data, you should use state instead.

Follow-up 3

What is the difference between state and props?

The main difference between state and props in React Native is that state is internal to a component and can be modified, while props are passed from a parent component and are read-only. State is used for managing component-specific data, while props are used for passing data between components.

Follow-up 4

Can you give an example of using props in React Native?

Sure! Here's an example of a parent component passing a prop to a child component:

// ParentComponent.js
import React from 'react';
import ChildComponent from './ChildComponent';

const ParentComponent = () => {
  const name = 'John';

  return (

  );
};

export default ParentComponent;

// ChildComponent.js
import React from 'react';

const ChildComponent = (props) => {
  return (
    Hello, {props.name}!
  );
};

export default ChildComponent;

In this example, the parent component ParentComponent passes a prop name with the value 'John' to the child component ChildComponent. The child component then accesses the prop using props.name and displays it in a Text component.

2. What is the state in React Native?

State is a component's own mutable, internal data that can change over time (user input, fetched data, toggles). When state updates, React re-renders the component to reflect the new value. Unlike props, state is owned and controlled by the component itself.

In modern React Native you manage state with hooks, primarily useState (and useReducer for more complex logic):

function Counter() {
  const [count, setCount] = useState(0);
  return (
     setCount((c) => c + 1)}>
      {count}

  );
}

Gotchas interviewers probe:

  • State updates are asynchronous and batched — don't read count right after setCount expecting the new value. Use the functional updater (setCount(c => c + 1)) when the next value depends on the previous one.
  • Treat state as immutable — create a new object/array instead of mutating, or React may not re-render.
  • The old this.state/setState class form is legacy; hooks are the standard.
  • For shared state across components, lift it up, use Context, or a library (Zustand/Redux Toolkit) — state itself is local to one component.
↑ Back to top

Follow-up 1

How is state used in React Native?

State is used in React Native to create dynamic and interactive components. It allows components to update and re-render based on changes in the state. By using state, you can create components that respond to user interactions, handle data input, and display different content based on the current state.

Follow-up 2

What is the difference between state and props?

In React Native, state and props are both used to manage data in components, but they have different purposes and behaviors:

  • State is used to manage internal component data that can change over time. It is owned and controlled by the component itself. State is mutable and can be updated using the setState method.

  • Props, short for properties, are used to pass data from a parent component to its child components. Props are immutable and cannot be changed by the child component. They are passed down from the parent and provide a way to configure and customize child components.

Follow-up 3

Can you give an example of using state in React Native?

Sure! Here's an example of a simple React Native component that uses state:

import React, { Component } from 'react';
import { View, Text, Button } from 'react-native';

class Counter extends Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
  }

  incrementCount = () => {
    this.setState(prevState => ({
      count: prevState.count + 1
    }));
  }

  render() {
    return (

        Count: {this.state.count}


    );
  }
}

export default Counter;

In this example, the Counter component has a state property called count which is initially set to 0. The incrementCount method is used to update the count state by incrementing it by 1. The current value of count is displayed in the Text component, and the Button component triggers the incrementCount method when pressed.

Follow-up 4

How do you update the state in a component?

To update the state in a React Native component, you can use the setState method provided by the Component class. The setState method accepts an object that represents the new state values you want to set. Here's an example:

this.setState({
  count: 10
});

In this example, the count state is updated to 10. It's important to note that setState is an asynchronous operation, so if you need to perform any actions after the state has been updated, you can pass a callback function as the second argument to setState:

this.setState({
  count: 10
}, () => {
  console.log('State updated!');
});

The callback function will be called after the state has been updated and the component has re-rendered.

3. How do you pass data from parent components to child components?

You pass data from parent to child through props. The parent sets attributes when rendering the child, and the child reads them as its arguments:

function Parent() {
  const user = { name: 'Sam', age: 30 };
  return ;
}

function Profile({ name, age }) {
  return {name} is {age};
}

Key points interviewers want:

  • Data flows one way (parent → child) and props are read-only in the child.
  • You can pass any value — strings, numbers, objects, arrays, functions, components — and use the special children prop for nested JSX.
  • To send data back up, the parent passes a callback prop that the child invokes (e.g. ``).
  • For data needed by many distant components, prop drilling gets painful — that's when you reach for Context or a state library (Zustand/Redux Toolkit) instead of threading props through every level.
↑ Back to top

Follow-up 1

What is the role of props in passing data?

Props play a crucial role in passing data from parent components to child components in React. They allow the parent component to pass any data or values to its child components. Props are read-only and cannot be modified by the child components. They are used to provide data or configuration to the child components and enable communication between components.

Follow-up 2

Can you pass data from child to parent components?

In React, data cannot be directly passed from child components to parent components. However, you can achieve this by using callback functions. The parent component can define a callback function and pass it as a prop to the child component. The child component can then invoke the callback function and pass the data as an argument. This allows the child component to indirectly pass data to the parent component.

Follow-up 3

What is the 'children' prop?

In React, the 'children' prop is a special prop that is automatically passed to every component. It represents the content between the opening and closing tags of a component. The 'children' prop can be used to access and render the content passed to a component. It allows components to be used as containers or wrappers for other components or elements.

Follow-up 4

Can you give an example of passing data from parent to child components?

Sure! Here's an example of passing data from a parent component to a child component in React:

// ParentComponent.js
import React from 'react';
import ChildComponent from './ChildComponent';

function ParentComponent() {
  const data = 'Hello, child!';

  return (
    <div>

    </div>
  );
}

export default ParentComponent;

// ChildComponent.js
import React from 'react';

function ChildComponent(props) {
  return (
    <div>
      <p>{props.data}</p>
    </div>
  );
}

export default ChildComponent;

In this example, the parent component ParentComponent passes the data variable as a prop to the child component ChildComponent. The child component then receives the data prop and renders it within a paragraph element.

4. What is the difference between state and props?

Both hold data that affects rendering, but they differ in ownership and mutability:

  • State is a component's own internal data that changes over time. It's mutable (via the updater from useState/useReducer, or legacy setState), and updating it triggers a re-render. State is private to the component unless deliberately shared.

  • Props are inputs passed in from a parent. They're read-only in the child — the child can't modify them. The parent owns them; when the parent passes new props, the child does re-render (correcting a common myth — prop changes do cause re-renders).

function Parent() {
  const [count, setCount] = useState(0);          // state: owned here
  return ;    // count passed down as a prop
}

The crisp summary: "state is internal and mutable; props are external and read-only." A clean mental model interviewers like: one component's state often becomes a child's props as it flows down the tree. Also note the modern phrasing — both are managed with hooks now (useState/useReducer), not this.state/this.setState.

↑ Back to top

Follow-up 1

When should you use state over props?

You should use state over props when:

  • The data is internal to the component and does not need to be shared with other components.
  • The data needs to be mutable and can change over time.
  • The component needs to re-render when the data changes.

Follow-up 2

When should you use props over state?

You should use props over state when:

  • The data needs to be passed from a parent component to a child component.
  • The data is read-only and should not be modified by the child component.
  • The component does not need to re-render when the data changes.

Follow-up 3

Can you give an example where both state and props are used?

Sure! Here's an example:

import React, { Component } from 'react';

class ParentComponent extends Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
  }

  render() {
    return (
      <div>

      </div>
    );
  }
}

class ChildComponent extends Component {
  render() {
    return (
      <div>
        <p>Count: {this.props.count}</p>
        Increment
      </div>
    );
  }
}

Follow-up 4

What happens when the state or props change?

When the state or props change in a React component, the component and its children will re-render to reflect the updated data. React uses a virtual DOM diffing algorithm to efficiently update only the parts of the DOM that have changed.

For state changes, you can use the setState() method to update the state. React will then compare the new state with the previous state and trigger a re-render if there are any differences.

For prop changes, React will automatically update the child component with the new props. The child component can access the new props using this.props and update its internal state or re-render as needed.

5. What is the lifecycle of a component in relation to state and props?

A component's lifecycle has three phases — mounting, updating, unmounting — and state/props drive the transitions: a state or prop change is what triggers an update (re-render). The key 2026 correction: in modern React Native you express all of this with hooks in function components, not class lifecycle methods.

The hook model (and its class equivalents):

  • Mounting — component is created and first rendered. Run setup (fetch data, subscribe) in useEffect(() =&gt; { ... }, []) (≈ componentDidMount). Initialize state with useState/useReducer.
  • Updating — when state or props change, the component re-renders. React to specific changes with useEffect(() =&gt; { ... }, [dep]), which fires whenever a listed dependency changes (≈ componentDidUpdate).
  • Unmounting — return a cleanup function from useEffect to tear down subscriptions/timers (≈ componentWillUnmount).
useEffect(() =&gt; {
  const sub = subscribe(userId);          // mount / when userId changes
  return () =&gt; sub.unsubscribe();          // cleanup on unmount or before re-run
}, [userId]);                              // re-runs when this prop changes

Gotchas interviewers want: the legacy componentWillMount/componentWillReceiveProps/componentWillUpdate methods are deprecated (UNSAFE-prefixed; old names removed in React 17), so don't cite them as current. Also note RN renders to native views, not the DOM — so "inserted into the DOM" is web phrasing; in RN the component is mounted into the native view tree.

↑ Back to top

Follow-up 1

What happens when the state changes?

When the state of a component changes, the render method is called again to update the component's UI. This means that any JSX returned by the render method will be re-rendered with the updated state values.

In addition to re-rendering the UI, the componentDidUpdate lifecycle method is also called after the state has been updated. This method can be used to perform additional actions or side effects based on the updated state values.

Follow-up 2

What happens when the props change?

When the props of a component change, the render method is called again to update the component's UI. This means that any JSX returned by the render method will be re-rendered with the updated prop values.

In addition to re-rendering the UI, the componentDidUpdate lifecycle method is also called after the props have been updated. This method can be used to perform additional actions or side effects based on the updated prop values.

Follow-up 3

How do lifecycle methods relate to state and props?

Lifecycle methods are closely related to state and props because they allow you to perform actions at specific points in the component's lifecycle when the state or props change.

For example, the componentDidMount method is called after the component has been inserted into the DOM and can be used to fetch data or initialize state. The componentDidUpdate method is called after the component's state or props have been updated and can be used to perform additional actions or side effects based on the updated values.

By using these lifecycle methods, you can control the behavior of your component based on changes in state or props.

Follow-up 4

Can you give an example of a lifecycle method handling state or props changes?

Sure! Here's an example of a lifecycle method, componentDidUpdate, handling state changes:

class ExampleComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
  }

  componentDidUpdate(prevProps, prevState) {
    if (this.state.count !== prevState.count) {
      console.log('State count has changed');
    }
  }

  render() {
    return (
      <div>
         this.setState({ count: this.state.count + 1 })}&gt;Increment
        <p>Count: {this.state.count}</p>
      </div>
    );
  }
}

Live mock interview

Mock interview: State and Props in React Native

Intermediate ~5 min Your own free AI key

Your voice and your AI key never touch our servers; the key stays in this browser and is sent only to Google. Only your round scores are saved to track progress.