{"id":29250,"date":"2021-02-15T15:49:19","date_gmt":"2021-02-15T23:49:19","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=29250"},"modified":"2022-07-20T08:43:50","modified_gmt":"2022-07-20T15:43:50","slug":"react-props","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/react-props\/","title":{"rendered":"React Props: The Basics"},"content":{"rendered":"\n<p>Have you ever seen the word \u201cprops\u201d in React, perhaps passed into a function? Ever wondered what it means? Due to the inherent importance of this object in React applications, it\u2019s important you understand why and how props and state are used.&nbsp;<\/p>\n\n\n\n<p>If you are confused about props you are not alone! Many of us are just used to seeing props passed in at certain points and go along with it almost subconsciously. Hopefully, this basic tutorial will help demystify why and how React props are used.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is React Props?<\/h2>\n\n\n\n<p>React props (\u201cproperties\u201d), are used as a way to pass data from one component (a parent component) to another (a child component). Props are immutable, which means that you can\u2019t change props passed to a component from within the component. Components receive data from other components with props. Props received from another component can\u2019t be modified.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Props Syntax<\/h2>\n\n\n\n<p>Here is a basic index.js file example showing props being passed in as an argument:<\/p>\n\n\n\n<p><em>\/\/Basic React import statements<\/em><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import React from 'react';\nimport ReactDOM from 'react-dom';<\/pre><\/div>\n\n\n\n<p><em>\/\/Movie component with a render function<\/em><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Movie extends React.Component {\n\t\trender() {\n\t\t\t  return &lt;h2&gt;Tonight we'll watch {this.props.title} !&lt;\/h2&gt;\n\t\t}\n}<\/pre><\/div>\n\n\n\n<p>Notice that we have not assigned the \u201ctitle\u201d property a value yet. We will do that in this next line:<\/p>\n\n\n\n<p><em>\/\/constant variable name \u201cmyelement\u201d<\/em><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const myelement = &lt;Movie title=&quot;Casablanca&quot; \/&gt;;<\/pre><\/div>\n\n\n\n<p>Here we ask our \u201cMovie\u201d component to display (by use of &lt;&#8230; \/&gt;) with the value \u201cCasablanca\u201d assigned to the property named \u201ctitle\u201d.&nbsp;<\/p>\n\n\n\n<p><em>\/\/React statement to render \u201cmyelement\u201d to the HTML element with the id named \u201croot\u201d.<\/em><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ReactDOM.render(myelement, document.getElementById('root'));<\/pre><\/div>\n\n\n\n<p>\u201cTonight we\u2019ll watch Casablanca !\u201d will be displayed.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sending Props to the Constructor and to super()<\/h2>\n\n\n\n<p>You may have seen props passed to constructor functions as well as into <em>super()<\/em> and&nbsp; been super (pun intended) confused about why.&nbsp; Here is a simplified example:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Computer extends React.Component{\n\t  constructor(props){ \n\t\t\tsuper(props); \/\/we passed in props to super()\n\t\t\tconsole.log(props);\n\t\t\tconsole.log(this.props);\n\t  }<\/pre><\/div>\n\n\n\n<p>Why do we call super and why pass props to it or the constructor? Super refers to the parent class constructor. If you have had significant programming experience, you\u2019ve dealt with constructors before. Our \u201cComputer\u201d class component extends from (in other words, it is constructed using) the basic React component (as you can see in the first line).&nbsp;<\/p>\n\n\n\n<p>So above we are initializing the React component\u2019s <em>this.props<\/em>. If we had not passed in <em>props<\/em> to <em>super()<\/em>, the last <em>console.log<\/em> statement would return as <em>undefined<\/em>. Basically, inside the constructor, you can\u2019t use \u201cthis\u201d unless you use <em>super(props)<\/em>. If that last <em>console.log<\/em> statement was written before <em>super(props)<\/em> it would not work.&nbsp;<\/p>\n\n\n\n<p>Even if you do not call <em>super()<\/em>, you\u2019ll still be able to access <em>this.props<\/em> in other parts of your component. This is because behind the scenes, React assigns <em>this.props<\/em> after the constructor runs. The issue is if you wanted to call a method from within the constructor itself. Coders include <em>super(props) <\/em>for code maintainability. Your code might change in the future and you want to be prepared if it does. Let\u2019s see the following code wherein we have a \u201cPerson\u201d class component with a property (\u201cname\u201d):<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Friend{\n\tconstructor(name){\n\t\tthis.name=name;\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Let\u2019s add a class \u201cGoodFriend\u201d which extends Friend:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class GoodFriend extends Friend{\n\t  constructor(name){\n\t\t    this.complimentYou(); \/\/you shouldn't do this before super()!\n\t\t    super(name);\n\t  }<\/pre><\/div>\n\n\n\n<p>\/\/the definition to the &#8220;complimentYou&#8221; function we called above:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>complimentYou() {\n     alert('You look nice today'); \/\/ an alert that shows up on your screen\n \t}\n }<\/pre><\/div>\n\n\n\n<p>The above works okay. However, if you later wanted to actually use <em>name<\/em> and add&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>alert('Compliment brought to you by your friend '+ this.name);<\/pre><\/div>\n\n\n\n<p>to the <em>complimentYou()<\/em> function, you\u2019d encounter a problem: the function is called in the constructor before we used <em>super(name)<\/em> to set up the parent\u2019s (\u201cFriend\u201d) <em>this.name<\/em>, so it would not work. This is why people call <em>super()<\/em> and pass props!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sending Props into a Component<\/h2>\n\n\n\n<p>Here is a way you can send props into a component:<\/p>\n\n\n\n<p>First, define the attribute\/value pair you want to send into the component:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>const elementToAdd = &lt;Band name=&quot;Velvet Underground&quot; \/&gt;;<\/pre><\/div>\n\n\n\n<p>Then pass along the argument you defined in the first step to the component as a props object:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Band extends React.Component {\n\t\trender(){\n\t\t\treturn &lt;h1&gt; The band name is {this.props.name}. &lt;\/h1&gt;;\n\t\t}\n\t}\nReactDOM.render(elementToAdd, document.getElementById('root'));<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Passing Data to Another Component with Props<\/h2>\n\n\n\n<p>You can send data through props into another component. A reason to do this is code cleanliness. React is all about breaking things up into reusable, manageable sections after all. Let\u2019s look at this example wherein we pass a name value.<\/p>\n\n\n\n<p>The \u201cBand\u201d component\u2019s <em>render()<\/em> function returns the value of the property named \u201cname\u201d (we will give it a value in the next component!) along with the string \u201cfrom New York City!\u201d:&nbsp;<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Band extends React.Component {\n\t  render() {\n            return &lt;h3&gt; {this.props.name} from New York City! &lt;\/h3&gt;;\n      }\n}<\/pre><\/div>\n\n\n\n<p>The \u201cVenue\u201d component\u2019s <em>render()<\/em> function returns a heading stating, \u201cBand Playing Today:\u201d. Under that we see our \u201cBand\u201d component we wrote above being called to be rendered; \u201cname\u201d is assigned the value of \u201cVelvet Underground\u201d:&nbsp;<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Venue extends React.Component {\n\t  render() {\n\t\t\treturn (\n\t\t\t\t\t&lt;div&gt;\n\t\t\t\t\t\t&lt;h1&gt;Band Playing Today:&lt;\/h1&gt;\n\t\t\t\t\t\t&lt;Band name=&quot;Velvet Underground&quot; \/&gt;\n\t\t\t\t\t&lt;\/div&gt;\n\t\t\t);\n\t  }\n}\n\nReactDOM.render(&lt;Venue \/&gt;, document.getElementById('root'));<\/pre><\/div>\n\n\n\n<p>Now a heading saying \u201cBand Playing Today:\u201d will be displayed along with \u201cVelvet Underground from New York City!\u201d In the last line, we only called <em>&lt;Venue \/&gt;<\/em> component to be rendered since \u201cvenue\u201d will already display our \u201cband\u201d component.&nbsp;<\/p>\n\n\n\n<p>Similarly, you can pass other forms of data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sudoku Board Section Example with Props<\/h2>\n\n\n\n<p>Imagine you have a sudoku game board you want to build with React. It\u2019s made up of nine, three-by-three square sections. Let\u2019s focus on one of those three-by-three square sections. It\u2019s basically a square board made of nine smaller squares, and each square has a number.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/-iTuOV8lOYqp_fzjsg7v52miA-19DLOQtPiJmGnxKXObKMwaT7N_mT9gfxkm9Mz0FCdBs91S1UMbU-_KmmqXLNsz75sgXV94pVXYp264bqkJhLWhoFNLAE-8XJ3RpJualkWmBVq4\" alt=\"\"\/><\/figure>\n\n\n\n<p>First, you create a \u201cSquare\u201d class with a <em>render()<\/em> method that would return a button. In your CSS file, you make it into a square shape using the <em>className<\/em> we tied to the button so you can refer to it. Notice also that the button content (what\u2019s displayed inside the button) is currently assigned to <em>{this.props.value}<\/em>, but \u201cvalue\u201d is not yet defined:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Square extends React.Component {\n  \t\trender() {\n    \t\t\t return ( \n      \t\t\t\t\t\t&lt;button className=&quot;smallSquare&quot;&gt; \n        \t\t\t\t\t\t\t{this.props.value}\n      \t\t\t\t\t\t&lt;\/button&gt;\n    \t\t\t );\n  \t\t}\n}<\/pre><\/div>\n\n\n\n<p>Now that we have the small squares taken care of, let\u2019s think of our sudoku board. We want to arrange these squares into three-by-three rows, and we want to fill these squares with numbers. Let\u2019s make our board component!<\/p>\n\n\n\n<p>We add the component heading and a function we\u2019ll name \u201cshowSquare\u201d. Look at the function\u2019s return statement. It calls our Square component and sets its value to \u201ci\u201d (remember we did not assign a value to the \u201cvalue\u201d property in our Square component).&nbsp; <br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Board extends React.Component {\n  \t\tshowSquare(i) {\n    \treturn &lt;Square value={i} \/&gt;;\n  \t  }<\/pre><\/div>\n\n\n\n<p>Now that we have the function that will use the square class and input a value \u201ci\u201d, let\u2019s use that in a render function to show our desired three-by-three board. We will call the renderSquare method on \u201cthis\u201d (meaning this component we are writing on, the Board component), and we will pass a number as the argument (the \u201ci\u201d in our function above):<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>render() {\nreturn (\n      &lt;div&gt;\n        &lt;div className=&quot;board-row&quot;&gt;\n          {this.renderSquare(9)}\n          {this.renderSquare(5)}\n          {this.renderSquare(2)}\n        &lt;\/div&gt;\n        &lt;div className=&quot;board-row&quot;&gt;\n          {this.renderSquare(3)}\n          {this.renderSquare(4)}\n          {this.renderSquare(1)}\n        &lt;\/div&gt;\n        &lt;div className=&quot;board-row&quot;&gt;\n          {this.renderSquare(6)}\n          {this.renderSquare(7)}\n          {this.renderSquare(8)}\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    );\n}\n  }<\/pre><\/div>\n\n\n\n<p>Notice also the <em>className<\/em> attribute I included here for each row &lt;div&gt;. You can, of course, call it something different than \u201cboard-row\u201d; I included it just to remind you to use that in your CSS file to format the square rows. This is an example of what the CSS section for the board row formatting might look like:&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>.board-row:after {\n  display: table;\n  content: &quot;&quot;;\n  clear: both;\n}<\/pre><\/div>\n\n\n\n<p>The last step would be to tell React to look at the DOM (Document Object Model) and render our board component to the HTML element that has the id set to \u201croot\u201d:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ReactDOM.render(\n  \t  &lt;Board \/&gt;,  document.getElementById('root')\n);<\/pre><\/div>\n\n\n\n<p>After this, you would want to build the interactive functionality of your game in another component, incorporating the two stateless components you built in this example. Interactive components are stateful, which means they have a state object that remembers and handles a collection of properties about a component. You\u2019d need state in your sudoku game to accept user input and keep track of numbers as well as to do other things, such as tell the user when they\u2019ve made a mistake or won the game.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Props vs State<\/h2>\n\n\n\n<p>Both props and state are objects in React which hold information about the component. It is what they do with that information that marks their differences. Props are immutable and are passed down from parent to child components, and child components can\u2019t modify the props. On the other hand, state stores information about the component which can be changed and updates itself accordingly. State can be used to store important information about a program.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>State and props are two concepts React users will come across. Remember that props are used to pass on information, or properties, from one component to the next. Although using state in React will add some more interactivity to your application, the tradeoff is that it will also add a lot of complexity.&nbsp;<\/p>\n\n\n\n<p>Stateless components are less complex and thereby easier to test and work with. When working on your next React project, definitely try to get more familiar with all you can do with props.<a href=\"https:\/\/dev.to\/myogeshchavan97\/how-to-create-a-spotify-music-search-app-in-react-328m\" target=\"_blank\" rel=\"noopener\" rel=\"nofollow\">&nbsp;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Have you ever seen the word \u201cprops\u201d in React, perhaps passed into a function? Ever wondered what it means? Due to the inherent importance of this object in React applications, it\u2019s important you understand why and how props and state are used.&nbsp; If you are confused about props you are not alone! Many of us&hellip;","protected":false},"author":114,"featured_media":17409,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-29250","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>React props: The Basics | Career Karma<\/title>\n<meta name=\"description\" content=\"A brief overview about React props. What the props object is and a few examples on how to use it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/react-props\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Props: The Basics\" \/>\n<meta property=\"og:description\" content=\"A brief overview about React props. What the props object is and a few examples on how to use it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/react-props\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-15T23:49:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-20T15:43:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"679\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yessenia Mata\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yessenia Mata\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/\"},\"author\":{\"name\":\"Yessenia Mata\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3\"},\"headline\":\"React Props: The Basics\",\"datePublished\":\"2021-02-15T23:49:19+00:00\",\"dateModified\":\"2022-07-20T15:43:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/\"},\"wordCount\":1415,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/react-props\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/react-props\/\",\"name\":\"React props: The Basics | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg\",\"datePublished\":\"2021-02-15T23:49:19+00:00\",\"dateModified\":\"2022-07-20T15:43:50+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3\"},\"description\":\"A brief overview about React props. What the props object is and a few examples on how to use it.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/react-props\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg\",\"width\":1020,\"height\":679},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/react-props\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/careerkarma.com\/blog\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"React Props: The Basics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3\",\"name\":\"Yessenia Mata\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2021\/02\/TD8SYPRGU-U01LTPHLWG2-ef37ec165b60-512-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2021\/02\/TD8SYPRGU-U01LTPHLWG2-ef37ec165b60-512-150x150.jpg\",\"caption\":\"Yessenia Mata\"},\"description\":\"Yessenia is a technical writer at Career Karma. In addition to contributing to Career Karma as a writer, Yessenia currently works in IT in the San Francisco Bay Area. She has experience with programming languages including Java, Python, HTML, CSS, and JavaScript and is double majoring in CNIT and Computer Science.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/yessenia-m\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"React props: The Basics | Career Karma","description":"A brief overview about React props. What the props object is and a few examples on how to use it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/react-props\/","og_locale":"en_US","og_type":"article","og_title":"React Props: The Basics","og_description":"A brief overview about React props. What the props object is and a few examples on how to use it.","og_url":"https:\/\/careerkarma.com\/blog\/react-props\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2021-02-15T23:49:19+00:00","article_modified_time":"2022-07-20T15:43:50+00:00","og_image":[{"width":1020,"height":679,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg","type":"image\/jpeg"}],"author":"Yessenia Mata","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Yessenia Mata","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/react-props\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/"},"author":{"name":"Yessenia Mata","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3"},"headline":"React Props: The Basics","datePublished":"2021-02-15T23:49:19+00:00","dateModified":"2022-07-20T15:43:50+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/"},"wordCount":1415,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/react-props\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/react-props\/","url":"https:\/\/careerkarma.com\/blog\/react-props\/","name":"React props: The Basics | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg","datePublished":"2021-02-15T23:49:19+00:00","dateModified":"2022-07-20T15:43:50+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3"},"description":"A brief overview about React props. What the props object is and a few examples on how to use it.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/react-props\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/react-props\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/react-props\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/05\/business-code-coding-computer-270360.jpg","width":1020,"height":679},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/react-props\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"React Props: The Basics"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/616533dc6ff37b9111aad55631595ec3","name":"Yessenia Mata","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2021\/02\/TD8SYPRGU-U01LTPHLWG2-ef37ec165b60-512-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2021\/02\/TD8SYPRGU-U01LTPHLWG2-ef37ec165b60-512-150x150.jpg","caption":"Yessenia Mata"},"description":"Yessenia is a technical writer at Career Karma. In addition to contributing to Career Karma as a writer, Yessenia currently works in IT in the San Francisco Bay Area. She has experience with programming languages including Java, Python, HTML, CSS, and JavaScript and is double majoring in CNIT and Computer Science.","url":"https:\/\/careerkarma.com\/blog\/author\/yessenia-m\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/29250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/114"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=29250"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/29250\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/17409"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=29250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=29250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=29250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}