<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl" -->

---
title: The Secret Of Controlling Component Instances In React
description: The key prop is used by React to identify which items have changed, are added, or are removed. Unmounting the previous instance simply means that all state...
canonical: https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: The Secret Of Controlling Component Instances In React | daily.dev
og:description: The key prop is used by React to identify which items have changed, are added, or are removed. Unmounting the previous instance simply means that all state...
og:url: https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl
og:image: https://api.daily.dev/og/posts/py9QHgphl.png
og:image:alt: The Secret Of Controlling Component Instances In React
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# The Secret Of Controlling Component Instances In React

**[Towards Dev](https://daily.dev/sources/towardsdev)** · 2 min read · 13 upvotes · 0 comments

## Summary

The key prop is used by React to identify which items have changed, are added, or are removed. Unmounting the previous instance simply means that all state that had existed in the component is completely removed. This is another little known secret about React key prop.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdev.com/the-secret-of-controlling-component-instances-in-react-abdf87854079?source=rss----a648dc4ecb66---4>

---

Tags: [#react](https://daily.dev/tags/react), [#javascript](https://daily.dev/tags/javascript), [#angular](https://daily.dev/tags/angular)

[View this post on daily.dev](https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"The Secret Of Controlling Component Instances In React","url":"https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl"},"datePublished":"2022-09-07T13:49:36.122Z","dateModified":"2022-09-07T13:49:36.121Z","description":"The key prop is used by React to identify which items have changed, are added, or are removed. Unmounting the previous instance simply means that all state...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/09edf3c88397f284e03f3bebb76eba76","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/09edf3c88397f284e03f3bebb76eba76","isAccessibleForFree":true,"articleSection":"Towards Dev","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Dev","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/2c710db2750a4a70835862534cb7c9d4","url":"https://daily.dev/sources/towardsdev"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/the-secret-of-controlling-component-instances-in-react-py9qhgphl","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":13},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"react,javascript,angular","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Dev","item":"https://daily.dev/sources/towardsdev"},{"@type":"ListItem","position":3,"name":"The Secret Of Controlling Component Instances In React"}]}
```

