<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>React &#8211; Sibeesh Passion</title>
	<atom:link href="https://www.sibeeshpassion.com/tag/react/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 20 Aug 2019 09:00:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>React &#8211; Sibeesh Passion</title>
	<link>https://www.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Iterating/Loop Through Your Component Property in Render Function in React</title>
		<link>https://www.sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/</link>
					<comments>https://www.sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 29 Oct 2018 14:28:32 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<category><![CDATA[codeproject]]></category>
		<category><![CDATA[React Component]]></category>
		<category><![CDATA[React Component Properties]]></category>
		<category><![CDATA[React Render Function and Loop]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=13314</guid>

					<description><![CDATA[[toc] Introduction I understand that you need to build some UI elements dynamically in your component&#8217;s render function in React. Yes! the only way is to loop through the items, you can either use a for loop or a map function to do so. But the real question is, are we allowed to do that in react? Unfortunately, not in a direct way, you may face some difficulty especially if you come from an Angular background. You were probably getting an error as &#8221; unused expression, expected an assignment or function call&#8221;, and now you are here in this page [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>[toc]</p>
<h2>Introduction</h2>
<p>I understand that you need to build some UI elements dynamically in your component&#8217;s render function in <a href="https://sibeeshpassion.com/category/react/">React</a>. Yes! the only way is to loop through the items, you can either use a for loop or a map function to do so. But the real question is, are we allowed to do that in react? Unfortunately, not in a direct way, you may face some difficulty especially if you come from an Angular background. You were probably getting an error as &#8221; unused expression, expected an assignment or function call&#8221;, and now you are here in this page for an easy solution. It isn&#8217;t that hard to achieve, I will explain how. I hope you will like it.</p>
<h2>Background</h2>
<p>I have an array of addresses and I need to show this in a print template, so I thought of creating a separate component which iterates through the item property. And each array element has its own property and I wanted to generate labels for each item. Here I am going to explain how I did it.</p>
<h2>Let&#8217;s start coding</h2>
<p>The first thing is, I have an interface for the address list properties as below.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">import { IAddressData } from "../../../interfaces/IAddressData";
export interface IAddressListProps {
    items: IAddressData[];
}</pre>
<p>Now I have created a component called PrintAddressList.tsx and written some code.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">import * as React from "react";
import { IAddressListProps } from '../../detailPage/components/interfaces/IAddressListProps';

export class PrintAddressList extends React.Component&lt;IAddressListProps, {}&gt;{
  constructor(props: IAddressListProps) {
    super(props);
  }

  public render(): React.ReactElement&lt;IAddressListProps&gt; {
    return (
      &lt;div&gt;
      &lt;/div&gt;
    );
  }
}</pre>
<p>And I need to have my custom labels for each address inside the div element in the render function. To do so, I had created a private function called createAddressCard which will loop through my props and return the HTML I need.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">private createAddressCard = () =&gt; {
    let parent = [];
    this.props.items.map((address) =&gt; {
      parent.push(&lt;div style={{ padding: '10px', border: '1px solid #ccc', margin: '5px' }}&gt;
        &lt;label&gt;{config.colNames.addressList.clmnAddressType}: &lt;/label&gt;
        &lt;label&gt;{address.Adressart}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnCompanyName}: &lt;/label&gt;
        &lt;label&gt;{address.Firma}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnPlaceName}: &lt;/label&gt;
        &lt;label&gt;{address.Ort}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnZipCode}: &lt;/label&gt;
        &lt;label&gt;{address.PLZ}&lt;/label&gt;&lt;br /&gt;
        &lt;label&gt;{config.colNames.addressList.clmnTelephone}: &lt;/label&gt;
        &lt;label&gt;{address.Telefon}&lt;/label&gt;&lt;br /&gt;
      &lt;/div&gt;);
    });
    return parent;
  }</pre>
<p>Now I can easily call this function inside the render function.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null">public render(): React.ReactElement&lt;IAddressListProps&gt; {
    return (
      &lt;div&gt;
        {this.createAddressCard()}
      &lt;/div&gt;
    );
  }</pre>
<p>Below is the complete code for the component.</p>
<p><a href="https://gist.github.com/SibeeshVenu/d2e11ed225a0568ded27c6f8fec0956c">https://gist.github.com/SibeeshVenu/d2e11ed225a0568ded27c6f8fec0956c</a></p>
<h2><span id="conclusion_1"><span id="conclusion">Conclusion</span></span></h2>
<p>In this post, we have learned how we can iterate our components properties inside a render function in the React component, for creating custom elements dynamically.</p>
<h2><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>
<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? If yes, please like/share/clap for me. Thanks in advance.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/iterating-loop-through-your-component-property-in-render-function-in-react/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Custom Horizontal Nav Component Using React Office UI Fabric</title>
		<link>https://www.sibeeshpassion.com/creating-a-custom-horizontal-nav-component-using-react-office-ui-fabric/</link>
					<comments>https://www.sibeeshpassion.com/creating-a-custom-horizontal-nav-component-using-react-office-ui-fabric/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Tue, 16 Oct 2018 21:37:40 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<category><![CDATA[Horizontal Nav in Office UI Fabric]]></category>
		<category><![CDATA[Nav in React]]></category>
		<category><![CDATA[Office UI Fabric]]></category>
		<category><![CDATA[React Component]]></category>
		<category><![CDATA[sharepoint]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=13281</guid>

					<description><![CDATA[[toc] Introduction Welcome to my blog. I assume that you are working in Office UI Fabric React components and you wanted to create a horizontal menu component in your react solution.&#160; Unfortunately, the normal Nav component in the Office UI Fabric doesn&#8217;t give you this option.&#160; And somehow you reached here by searching for a solution to implement the horizontal menu. You are in the right place then. Let&#8217;s skip the talking and jump into the code.&#160; I hope you will like this article. Let&#8217;s start coding. Source Code The source code can be found here. Background As I mentioned [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>[toc]</p>



<h2 class="wp-block-heading">Introduction</h2>



<p>Welcome to my blog. I assume that you are working in Office UI Fabric React components and you wanted to create a horizontal menu component in your react solution.&nbsp; Unfortunately, the normal Nav component in the Office UI Fabric doesn&#8217;t give you this option.&nbsp; And somehow you reached here by searching for a solution to implement the horizontal menu. You are in the right place then. Let&#8217;s skip the talking and jump into the code.&nbsp; I hope you will like this article. Let&#8217;s start coding.</p>



<h2 class="wp-block-heading">Source Code</h2>



<p>The source code can be found <a href="https://github.com/SibeeshVenu/Office-UI-Fabric-React-Horizontal-Nav">here</a>.</p>



<h2 class="wp-block-heading">Background</h2>



<p>As I mentioned in the introduction, there is no option to make a horizontal menu if you are using <a href="https://developer.microsoft.com/en-us/fabric#/components/nav">UI Fabric Nav component</a>. And I also ended up in spending some time playing with the Nav component to make it horizontal, but it wasn&#8217;t working as expected. And I found a different way to achieve the same, hereby I am sharing it as I couldn&#8217;t find such a solution on the internet.&nbsp; You can always see my answer <a href="https://sharepoint.stackexchange.com/questions/235501/fabric-ui-navbar-components-how-to-swtich-to-horizontal-layout/250919#250919">here</a> on <a href="https://stackoverflow.com/users/5550507/sibeesh-venu">StackOverflow</a>.</p>



<figure class="wp-block-image alignnone"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/10/Nav-menu-vertical.png"><img fetchpriority="high" decoding="async" width="446" height="1025" src="https://sibeeshpassion.com/wp-content/uploads/2018/10/Nav-menu-vertical.png" alt="Nav menu vertical" class="wp-image-13282" srcset="/wp-content/uploads/2018/10/Nav-menu-vertical.png 446w, /wp-content/uploads/2018/10/Nav-menu-vertical-131x300.png 131w, /wp-content/uploads/2018/10/Nav-menu-vertical-400x919.png 400w, /wp-content/uploads/2018/10/Nav-menu-vertical-261x600.png 261w" sizes="(max-width: 446px) 100vw, 446px" /></a><figcaption>Nav menu vertical</figcaption></figure>



<h2 class="wp-block-heading">Creating Horizontal Nav component</h2>



<p>I believe that you have already created your solution and you are just trying to create a new Menu web part in the existing solution. If you haven&#8217;t created a solution, you can create one using the below command.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">yo @microsoft/sharepoint</pre>



<h3 class="wp-block-heading">MenuWebPart.ts</h3>



<p>Once you have created a new web part, you can see that there is a file called MenuWebPart.ts. This is the file we are going to edit first. You can see the content of that file below.</p>



<script src="https://gist.github.com/SibeeshVenu/13b21a27e09c6d3b5b4ef7c461601af8.js"></script>



<p>As you can see I am calling the Menu component here with the property items, this is where you need to mention the contents of your menu.</p>



<h3 class="wp-block-heading">Menu.tsx</h3>



<p>Now let&#8217;s start editing the code in Menu.tsx file.</p>



<script src="https://gist.github.com/SibeeshVenu/e00cfcb9e94fbd6c3edce04a5d8cbc87.js"></script>



<p>As you can see that I am using CommandBar here which accepts the items property which we have set before.</p>



<h3 class="wp-block-heading">IMenuProps.ts</h3>



<p>You would also need to add the items property in the IMenuProps.ts file.</p>



<script src="https://gist.github.com/SibeeshVenu/83bb889668b07bff561f6039f277a792.js"></script>



<h2 class="wp-block-heading">Output</h2>



<p>If you have configured the CommandBar component in an above-mentioned way, you would have seen a horizontal menu by now. Please be keep in mind that there are some limitations using in <a href="https://developer.microsoft.com/en-us/fabric#/components/commandbar">CommandBar</a>. I would use this until Microsoft introduces a new property in the existing Nav component to make it horizontal.</p>



<figure class="wp-block-image alignnone"><a href="https://sibeeshpassion.com/wp-content/uploads/2018/10/Nav-horizontal-e1539726187582.png"><img decoding="async" src="https://sibeeshpassion.com/wp-content/uploads/2018/10/Nav-horizontal-e1539726187582.png" alt="Nav horizontal" class="wp-image-13286"/></a><figcaption>Nav horizontal</figcaption></figure>



<h2 class="wp-block-heading"><span id="conclusion_1"><span id="conclusion">Conclusion</span></span></h2>



<p>Thanks a lot for reading. Did I miss anything that you may think which is needed? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>



<h2 class="wp-block-heading"><span id="your-turn-what-do-you-think">Your turn. What do you think?</span></h2>



<p>A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>



<p>Kindest Regards<br>Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sibeeshpassion.com/creating-a-custom-horizontal-nav-component-using-react-office-ui-fabric/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
