{"id":2775,"date":"2018-11-07T12:01:15","date_gmt":"2018-11-07T12:01:15","guid":{"rendered":"https:\/\/tinjurewp.com\/jsblog\/?p=2775"},"modified":"2018-11-07T12:01:15","modified_gmt":"2018-11-07T12:01:15","slug":"working-with-functions-and-array-map-method-in-reactjs","status":"publish","type":"post","link":"https:\/\/learncode.tinjurewp.com\/working-with-functions-and-array-map-method-in-reactjs\/","title":{"rendered":"Working with Functions and Array.Map() Method in ReactJS"},"content":{"rendered":"<p class=\"note\"><strong>Note<\/strong>: This is part 1 of three-part prerequisite post series. A\u00a0 prior knowledge of these topics is essential before deep diving into <em>Creating List React component<\/em>.<\/p>\n<p>In the previous learning-note post\u00a0<a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-to-work-with-react-components\/\" target=\"_blank\" rel=\"noopener\">Learning to Work With React Components<\/a>, how to build a simple react component using run time <code>&lt;script&gt;<\/code>in a HTML file were discussed. Although slow, this approach is not ideal for react app development, however it is ideal for my current learning purposes.<\/p>\n<p>The purpose of this learning-note post series is to understand how a simple list react component is created and apply that knowledge to build <code>BlogPost<\/code> component to list posts in a page.<\/p>\n<h5 id=\"javascript-prerequisite\">JavaScript Prerequisite<\/h5>\n<p>Because creating List component <a href=\"https:\/\/reactjs.org\/\" target=\"_blank\" rel=\"noopener\">ReactJS<\/a> is advanced topic, it requires working JS knowledge in the following areas:<\/p>\n<div class=\"article-series\"><strong>Post Series<\/strong><br \/>\n<strong>Part 1<\/strong>: JavaScript Fundamentals &#8211; Array.Map(), Arrow Functions &amp; Functions (<strong>this post<\/strong>)<br \/>\nPart 2: <a href=\"https:\/\/tinjurewp.com\/jsblog\/understanding-how-props-are-passed-to-react-component\/\" target=\"_blank\" rel=\"noopener\">How to Pass Props (Data Objects) to Component in ReactJS<\/a><br \/>\nPart 3: <a href=\"https:\/\/tinjurewp.com\/jsblog\/creating-list-component-in-reactjs\/\" target=\"_blank\" rel=\"noopener\">Creating List Component in ReactJS<\/a><\/div>\n<p>The objective of this learning-post to review JavaScript (JS) fundamentals, for example <em>functions<\/em>, <em>array function<\/em>, <code>map()<\/code> &amp; <code>array.map()<\/code> methods to apply in creating a List react component.<\/p>\n<h4>Arrow Functions in React Component<\/h4>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions\" target=\"_blank\" rel=\"noopener\">Arrow functions<\/a> are discussed in detail in another post <a href=\"https:\/\/tinjurewp.com\/jsblog\/understanding-javascript-arrow-functions\/\" target=\"_blank\" rel=\"noopener\">understanding JavaScript arrow function<\/a>. Revisiting basic arrow function syntax:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/arrow function syntax\n    () =&gt; { ... } \/\/ with no parameter\n     x =&gt; { ... } \/\/ with one parameter\n(x, y) =&gt; { ... } \/\/ with several parameters<\/code><\/pre>\n<p><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Functions\/Arrow_functions\" target=\"_blank\" rel=\"noopener\">Arrow function<\/a> syntax is commonly used in react <a href=\"https:\/\/reactjs.org\/docs\/components-and-props.html#function-and-class-components\" target=\"_blank\" rel=\"noopener\">functional (stateless) components<\/a> because of its concise code. Some use case examples of arrow functions in react is shown below.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/syntax - with no argument\n() =&gt; { statements }\n\n\/\/ES5 syntax\nlet myComp = function jsLearn() {\n    return &#039;Welcome to ReactJs&#039;;\n    };\n\n\/\/ES6 syntax\nlet myComp = () =&gt; { return &#039;Welcome to ReactJs&#039; };<\/code><\/pre>\n<p>In the example above, a very basic react functional component <code>myComp<\/code> with ES5 syntax (lines:\u00a0 5-7) can be written in a single line (line 10) with ES6 arrow function syntax. It is concise and easy to read too.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/ ES5 function syntax\nfunction helloWorld() {\n    return &#039;Hello World! Welcome to reactJs&#039;;\n  }\n  \n  \/\/ ES6 arrow function syntax with return\n  const HelloWorld = () =&gt; {\n    return &#039;Hello World! Welcome to reactJs&#039;;\n  }\n  \n  \/\/ ES6 arrow function without return\n  const HelloWorld = () =&gt;\n    &#039;Hello World! Welcome to reactJs&#039;;<\/code><\/pre>\n<p>In the example above, a use case example of a basic react functional component <code>helloWorld<\/code> with ES5 syntax (lines: 2-4) is written with ES6 arrow function with use <code>return<\/code> keyword (lines: 7-9) and without <code>return<\/code> keyword (lines: 12-13) is shown.<\/p>\n<h6><a href=\"https:\/\/reactjs.org\/docs\/components-and-props.html#function-and-class-components\" target=\"_blank\" rel=\"noopener\">Functions as React Component<\/a><\/h6>\n<p>React component can be written with a simple JS functions as functional components. <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-reactjs-a-basic-overview\/#functional-component\" target=\"_blank\" rel=\"noopener\">Functional (stateless) component<\/a> was briefly discussed in a previous post. Functional component do not manage state (<em><strong>stateless<\/strong><\/em>) and are not aware of its own <a href=\"https:\/\/reactjs.org\/docs\/state-and-lifecycle.html\" target=\"_blank\" rel=\"noopener\">state<\/a>. Their main purpose is \u201c<em>presentational<\/em>\u201d i.e. to to receive data and present as JSX. It requires <a href=\"https:\/\/reactjs.org\/docs\/rendering-elements.html\" target=\"_blank\" rel=\"noopener\">rendering mechanism<\/a> <code>render()<\/code> method from React component.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/functional component\nfunction Greeting(props) {\n  return &lt;h1&gt;Hello, {props.name}&lt;\/h1&gt;;\n}<\/code><\/pre>\n<p>In the example above, the <code>Greeting<\/code> component receives a single <em>props<\/em> (which is short for <em>properties<\/em>) object argument with data and return a react element. Functional components are easy to write and preferred method of creating react components when no state or methods (class or <a href=\"https:\/\/reactjs.org\/docs\/state-and-lifecycle.html\" target=\"_blank\" rel=\"noopener\">lifecycle<\/a>) is not required.<\/p>\n<p>The examples used in arrow functions in previous section can be written as functional (stateless) components as shown below:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/ JavaScript ES5 function\nfunction Hello(props) {\n  return &lt;h1&gt;{props.name}&lt;\/h1&gt;;\n}\n\/\/ JavaScript ES6 arrow function\nconst Hello = (props) =&gt; {\n  return &lt;h1&gt;{props.name}&lt;\/h1&gt;;\n}\n\/\/ JavaScript ES6 arrow function without body and implicit return\nconst Hello = (props) =&gt;\n  &lt;h1&gt;{props.name}&lt;\/h1&gt;<\/code><\/pre>\n<p>In the example above, arrow functions were used to write simple functional component. Because of their simple syntax and easy to read, most functional components are written using arrow functions.<\/p>\n<p>This section of the post is inspired by <a href=\"https:\/\/www.robinwieruch.de\/about\/\" target=\"_blank\" rel=\"noopener\">Robin Wieruch<\/a>\u2019s <a href=\"https:\/\/www.robinwieruch.de\/javascript-fundamentals-react-requirements\/\" target=\"_blank\" rel=\"noopener\">JavaScript fundamentals before learning React<\/a> post.<\/p>\n<h4>Revisiting map() and Array.map() Methods<\/h4>\n<p>In previous post on <a href=\"https:\/\/tinjurewp.com\/jsblog\/understanding-javascript-arrow-functions\/\" target=\"_blank\" rel=\"noopener\">JavaScript Arrow Functions<\/a>, use case example of <a href=\"https:\/\/tinjurewp.com\/jsblog\/understanding-javascript-arrow-functions\/#array-mapping\" target=\"_blank\" rel=\"noopener\">array.mapping<\/a> was discussed briefly. In this section we will deep dive into\u00a0 its basic syntax, how it it applied in ReactJS.<\/p>\n<h6>Prerequisites<\/h6>\n<p>An understanding of following topics is essential before starting jumping into List react component. The purpose of this post is to revisit the following topics discussed in <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-maps-sets\/\" target=\"_blank\" rel=\"noopener\">previous posts<\/a> and assemble relevant use case examples of iterating objects, arrays \u2026.<\/p>\n<ul>\n<li><a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-methods\/#array-map\" target=\"_blank\" rel=\"noopener\">Array.map() method<\/a>: It is discussed in previous post. Maps are commonly used to transform an array of items into a different array of exact same length without affecting the original array.<\/li>\n<li><a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-methods\/#array-filter\" target=\"_blank\" rel=\"noopener\">Array.filter() method<\/a>: If from an array of items, we would like to filter out certain items into an new array <code>filter()<\/code> method is used. The length of the new array will be shorter (if some items were excluded) or same (if no items were excluded).<\/li>\n<li><a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-methods\/#array-reduce\" target=\"_blank\" rel=\"noopener\">Array.reduce() method<\/a>: This is discussed in more detail in a <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-reduce-method\/\" target=\"_blank\" rel=\"noopener\">previous<\/a> post including use case examples of <code>reduce()<\/code> method in finding an average, creating a tally and flattening\u00a0 nested arrays into a single array.<\/li>\n<\/ul>\n<h6>Use Case Example of <code>&lt;a href=&quot;https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Array.map()&lt;\/a&gt;<\/code> method<\/h6>\n<p>The following use case examples are inspired by and adopted from <em>John Ferris<\/em>\u2018s post\u00a0<a href=\"https:\/\/atendesigngroup.com\/blog\/array-map-filter-and-reduce-js\" target=\"_blank\" rel=\"noopener\">Array Map, Filter and Reduce in JS<\/a>.<\/p>\n<p>The following example of blog posts array contains several posts with different author, tag and text.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/an array of blog posts\nconst posts = [\n  {\n    title: &#039;Hello, World!&#039;,\n    text: &#039;Lorem ipsum dolor sit amet&#039;,\n    tag: &#039;General&#039;\n  },\n  {\n    title: &#039;Welcome to React&#039;,\n    text: &#039;Lorem ipsum dolor sit amet&#039;,\n    tag: &#039;React&#039;\n  },\n  {\n    title: &#039;Learning React&#039;,\n    text: &#039;Lorem ipsum dolor sit amet&#039;,\n    tag: &#039;React&#039;\n  },\n  {\n    title: &#039;Learning JavaScript&#039;,\n    text: &#039;Lorem ipsum dolor sit amet&#039;,\n    tag: &#039;JavaScript&#039;\n  }\n];<\/code><\/pre>\n<p>For example, if we would like to list all the posts or lists only posts which meets certain selection criteria (<em>eg<\/em>. React tag), it can be performed using <code>Array.map()<\/code> method.<\/p>\n<h5>Array.Map() Method<\/h5>\n<p>The basic syntax of the <code>&lt;a href=&quot;https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map#Syntax&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Array.map()&lt;\/a&gt;<\/code> method is shown below.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/basic syntax\nconst new_array = Array.prototype.map(callback(item));\n\n\/\/full syntax\nconst new_array = Array.prototype.map(callback(item[, index], array])\n                 [, thisArg]);<\/code><\/pre>\n<p>To quote from the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map#Description\" target=\"_blank\" rel=\"noopener\">MDN documentaion<\/a> &#8220;<em>the <code>map<\/code> calls a provided <code>callback<\/code> function <strong>once for each element<\/strong> in an array, in order, and constructs a new array from the results<\/em>&#8220;.<\/p>\n<p>Additional Information: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map#Description\" target=\"_blank\" rel=\"noopener\">MDN Documentaion<\/a><\/p>\n<p>In the following example, use of <code>array.map()<\/code> to list only <em>tags<\/em> of each blog posts is shown.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/mapping\nfunction getTag(post) {\n  return post.tag;\n}\n\/\/map syntax\nconst postTags = posts.map(getTag);\n\n\/\/map using 2015 arrow function syntax\npostTags = posts.map(post =&gt; post.tag);\n\n\/\/console print\nconsole.log(postTags);\n\/\/OUTPUT\n(4)\u00a0[&quot;General&quot;, &quot;React&quot;, &quot;React&quot;, &quot;JavaScript&quot;]<\/code><\/pre>\n<p>In the example above, <code>map()<\/code> method iterates each item in <code>posts<\/code> array and returns each iteration of the loop to the console (line 14) one at a time until all the elements are printed. The <code>map()<\/code> method is assigned to the <code>postTags<\/code> variable.<\/p>\n<p>Using ES5 arrow function syntax the mapping function (lines: 2-6) can be written in a single line (line 9) which is simple and easy to read.<\/p>\n<h6>Array.Filter() Method<\/h6>\n<p>The <code>&lt;a href=&quot;https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Array.filter()&lt;\/a&gt;<\/code> method is useful to filter out list of posts that meet certain selection criteria. The basic <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter#Syntax\" target=\"_blank\" rel=\"noopener\">syntax<\/a> of <code>array.filter()<\/code> is shown below:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/basic syntax\nconst new_array = Array.prototype.filter(callback(item));\n\n\/\/full syntax\nvar newArray = arr.filter(callback(element[, index[, array]])\n               [, thisArg])<\/code><\/pre>\n<p>To quote from the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter#Description\" target=\"_blank\" rel=\"noopener\">MDN<\/a>, &#8221; <em>the\u00a0<code>filter()<\/code> calls a provided <code>callback<\/code> function once for each element in an array, and constructs a new array of all the values for which <code>callback<\/code> returns <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Truthy\">a value that coerces to <code>true<\/code><\/a><\/em> &#8220;.<\/p>\n<p>In the following example, use of <code>array.filter()<\/code> method to list posts with React tag only is shown.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/filter condition\nfunction isReact(post) {\n  return post.tag === &#039;React&#039;;\n}\n \/\/array filter with React post tag\nconst reacts = posts.filter(isReact);<\/code><\/pre>\n<p>In the above example, post which meets <code>post.tag === &#039;React&#039;<\/code> condition (line 3) and return <code>true<\/code> are printed in the console (below).<\/p>\n<pre class=\"line-numbers\" data-start=\"7\"><code class=\"language-javascript\">\/\/console print\nconsole.log(reacts);\n\n\/\/OUTPUT\n\/\/(2) [{..},{..}]\n[ \n   {\n    tag: &quot;React&quot;\n    text: &quot;Lorem ipsum dolor sit amet&quot;\n    title: &quot;Welcome to React&quot;\n  },\n  {\n    tag: &quot;React&quot;\n    text: &quot;Lorem ipsum dolor sit amet&quot;\n    title: &quot;Learning React&quot;\n  }\n ]<\/code><\/pre>\n<p>The above console result shows that only two posts meet the selection criteria and the two posts array are listed (lines: 11-23).<\/p>\n<h6>Array.Reduce() Method<\/h6>\n<p>JavaScript <code>&lt;a href=&quot;https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/Reduce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Array.prototype.reduce()&lt;\/a&gt;<\/code> method is important in performing tasks like flattening arrays, tallying array items etc. it is discussed in a separate post <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-reduce-method\/\" target=\"_blank\" rel=\"noopener\">JavaScript Array.Reduce() Method<\/a>. Revisiting <code>array.reduce()<\/code> basic syntax from the <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-reduce-method\/#array-reduce-method-syntax\" target=\"_blank\" rel=\"noopener\">previous<\/a> post:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">\/\/without initial value\nlet reducer = arr.reduce(callback);\n\/\/callback function\nlet callbackName = function(accu, curVal, cumInd, arr) {\n  return accu + curr;\n });\n\n\/\/Arrow function syntax\nlet reducer = function(accu, curVal, cumInd, arr) =&gt; accu + curr;<\/code><\/pre>\n<p>The <code>array.reduce()<\/code> method performs callback function once on each array elements (from left to right) reducing into a single value. How <code>array.reduce()<\/code> method works with some use case examples are discussed in <a href=\"https:\/\/tinjurewp.com\/jsblog\/learning-javascript-array-reduce-method\/\" target=\"_blank\" rel=\"noopener\">other post<\/a>.<\/p>\n<p>Additional Information:\u00a0<a href=\"https:\/\/atendesigngroup.com\/blog\/array-map-filter-and-reduce-js\" target=\"_blank\" rel=\"noopener\">Array Map, Filter and Reduce in JS<\/a> | <a href=\"https:\/\/atendesigngroup.com\/\" target=\"_blank\" rel=\"noopener\">ATEN<\/a><\/p>\n<h4>Map, Reduce &amp; Filter in React<\/h4>\n<p>The following use case examples are inspired by and adopted from <em>Robin Wieruch<\/em>\u2019s post <a href=\"https:\/\/www.robinwieruch.de\/javascript-fundamentals-react-requirements\/#react-javascript-map-reduce-filter\" target=\"_blank\" rel=\"noopener\">Map, Reduce and Filter in React<\/a>.<\/p>\n<p>React has no separate API to list items and vanilla JS <code>map()<\/code> method is used to iterate items in react component.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">import React, { Component } from &#039;react&#039;;\n\nclass App extends Component {\n  render() {\n    var posts = [\n      { title: &#039;Hello, World&#039; },\n      { title: &#039;Welcome to React&#039; },\n    ];\n     \/\/ ES5 syntax\n    return (\n      &lt;ul&gt;\n        {posts.map(function (post) {\n          return &lt;li&gt;{post.title}&lt;\/li&gt;;\n        })}\n      &lt;\/ul&gt;\n    );\n\n   \/\/ ES6 arrow functions syntax\n   \/* return (\n     &lt;ul&gt;\n        {posts.map(post =&gt; &lt;li&gt;{post.title}&lt;\/li&gt;)}\n     &lt;\/ul&gt;\n   ); *\/\n\n  }\n}\n\nexport default App;<\/code><\/pre>\n<p>In the above example, the App component contain a <strong>posts<\/strong> array with two items (lines: 5-8). The items are rendered as <code>&lt;ul&gt;<\/code> list items using <code>map()<\/code> method (lines: 10-16). The ES5 syntax can be simplified with ES6 arrow function syntax (line 21).<\/p>\n<p>In the following example code, filtering list array in React component with <code>filter()<\/code> is illustrated.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-javascript\">class App extends Component {\n  render() {\n    var posts = [\n      { title: &#039;Hello, World&#039;, \n        isReact: &#039;false&#039;\n       },\n      { title: &#039;Welcome to React&#039;, \n        isReact: &#039;true&#039;\n      },\n    ];\n\n    return (\n       &lt;ul&gt;\n         {posts\n           .filter(post =&gt; post.isReact)\n           .map(post =&gt; &lt;li&gt;{post.title}&lt;\/li&gt;)\n         }\n       &lt;\/ul&gt;\n     );\n  }\n}\n\nexport default App;<\/code><\/pre>\n<p>Similarly, it can <code>reduce()<\/code> method can be applied in react component.<\/p>\n<p>Additional Information: <a href=\"https:\/\/www.robinwieruch.de\/javascript-fundamentals-react-requirements\/#react-javascript-map-reduce-filter\" target=\"_blank\" rel=\"noopener\">Map, Reduce and Filter in React<\/a> in <a href=\"https:\/\/www.robinwieruch.de\/javascript-fundamentals-react-requirements\/\" target=\"_blank\" rel=\"noopener\">JavaScript fundamentals before learning React<\/a>.<\/p>\n<h5>Wrapping Up<\/h5>\n<p>In this learning to create List react component series, essential JS kn<em>o<\/em>wledge required is reviewed. Use of <code>map()<\/code> method to list an array items in react component was illustrated. More detail listing will be discussed in Part 3: Creating List React Component.<\/p>\n<p>Part 2: <a href=\"https:\/\/tinjurewp.com\/jsblog\/understanding-how-props-are-passed-to-react-component\/\" target=\"_blank\" rel=\"noopener\">How to Pass Props (Data Objects) to Component in ReactJS<\/a><\/p>\n<h6>Useful Resources and Links<\/h6>\n<p>While preparing this post, I have referred the following references extensively. Please to refer original posts for more detailed information.<\/p>\n<ul>\n<li><a href=\"https:\/\/www.robinwieruch.de\/javascript-fundamentals-react-requirements\/#react-javascript-map-reduce-filter\" target=\"_blank\" rel=\"noopener\">JavaScript fundamentals before learning React<\/a> | <a href=\"https:\/\/www.robinwieruch.de\/\" target=\"_blank\" rel=\"noopener\">Robin Wieruch<\/a><\/li>\n<li><a href=\"https:\/\/atendesigngroup.com\/blog\/array-map-filter-and-reduce-js\" target=\"_blank\" rel=\"noopener\">Array Map, Filter and Reduce in JS<\/a> | <a href=\"https:\/\/atendesigngroup.com\/\" target=\"_blank\" rel=\"noopener\">ATEN<\/a><\/li>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map\" target=\"_blank\" rel=\"noopener\"><code>Array.prototype.map()<\/code> method<\/a> | MDN Documentation<\/li>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filter\" target=\"_blank\" rel=\"noopener\"><code>Array .prototype.filter()<\/code> method<\/a> | MDN Documentation<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Note: This is part 1 of three-part prerequisite post series. A\u00a0 prior knowledge of these topics is essential before deep diving into Creating List React component. In the previous learning-note post\u00a0Learning to Work With React Components, how to build a simple react component using run time &lt;script&gt;in a HTML file were discussed. Although slow, this [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[41,48,5],"tags":[],"class_list":["post-2775","post","type-post","status-publish","format-standard","hentry","category-functions","category-map-set","category-reactjs"],"_links":{"self":[{"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/posts\/2775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/comments?post=2775"}],"version-history":[{"count":0,"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/posts\/2775\/revisions"}],"wp:attachment":[{"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/media?parent=2775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/categories?post=2775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learncode.tinjurewp.com\/wp-json\/wp\/v2\/tags?post=2775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}