<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Talha Munir on Medium]]></title>
        <description><![CDATA[Stories by Talha Munir on Medium]]></description>
        <link>https://medium.com/@mtalham?source=rss-2e320cf066a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qi4_fI8AJdFC9lro</url>
            <title>Stories by Talha Munir on Medium</title>
            <link>https://medium.com/@mtalham?source=rss-2e320cf066a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:30:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mtalham/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build Web Component with React and use it in an Angular app]]></title>
            <link>https://mtalham.medium.com/build-web-component-with-react-and-use-it-in-an-angular-app-515c2fed6a53?source=rss-2e320cf066a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/515c2fed6a53</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Talha Munir]]></dc:creator>
            <pubDate>Mon, 24 May 2021 17:50:58 GMT</pubDate>
            <atom:updated>2021-05-24T18:01:30.960Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I use <a href="https://www.npmjs.com/package/react-to-webcomponent">react-to-webcomponent</a> to package a React app as a web-component and use it as a micro frontend in an Angular app.</p><p>Here’s what we create in this article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkOQsQPAyS0uildH0VR0MQ.png" /><figcaption>Angular app using web-component to show list</figcaption></figure><p>The react application is very basic to show a list of string by using Material UI. To show how to pass data from another app, the list is provided as props from an angular app. While angular app is sending data and provide search functionality and also reusing web-component to show the list.</p><p>It’s not possible to show all the code here but if you want to follow along use the code here: <a href="https://github.com/mtalham/react-web-component">Example code of React</a> and <a href="https://github.com/mtalham/ng-react-webcomponent-example">Example code of Angular </a>.</p><h3>Steps to convert React component to custom element</h3><ol><li>After creating a react app, add react-to-webcomponent library:</li></ol><pre>yarn add react-to-webcomponent</pre><p>2. Import react-to-webcomponent into index.js and use the reactToWebComponent function exported from the module to create a web-component and then register that component. The code is shown below:</p><pre>import reactToWebComponent from &quot;react-to-webcomponent&quot;;</pre><pre>const app = reactToWebComponent(App, React, ReactDOM);<br>customElements.define(&quot;app-webcomponent&quot;, app);</pre><p>3. Build the app by running yarn build and then you can use new html tag &lt;app-webcomponent&gt;&lt;/app-webcomponent&gt; in another website by adding a script tag that points to the file created by the build script.</p><h3>Host the build files locally</h3><p>You can follow the following steps to server the static files for test purposes.</p><p>1. I have used the following script to merge the build files into one single file with name main.js.</p><pre>#!/usr/bin/env node</pre><pre>const { readFile } = require(&quot;fs&quot;).promises;<br>const concat = require(&quot;concat&quot;);</pre><pre>(async function build() {<br>  try {<br>    const assetManifestPath = &quot;./build/asset-manifest.json&quot;;<br>    const { entrypoints } = JSON.parse(<br>      await readFile(assetManifestPath, &quot;utf8&quot;)<br>    );<br>    const filePaths = entrypoints<br>      .filter((path) =&gt; /\.js$/.test(path))<br>      .map((path) =&gt; `./build/${path}`);<br>    const outFile = &quot;./build/main.js&quot;;<br>    await concat(filePaths, outFile);<br>    console.log(<br>      `Concatenated the following files into ${outFile}\n\n${filePaths.join(&quot;\n&quot;)}`<br>    );<br>  } catch (error) {<br>    console.error(error);<br>  }<br>})();</pre><p>2. You need to update your build script inside package.json file.</p><pre>&quot;build&quot;: &quot;react-scripts build &amp;&amp; ./concatBuiltJs.js&quot;</pre><p>3. Install <a href="https://www.npmjs.com/package/http-server">http-server</a> if it is not already installed on you machine.</p><pre>yarn global add http-server</pre><p>4. Run the following command from your project to serve build files</p><pre>http-server -p 4202 build</pre><h3>Use web-component in an Angular app</h3><ol><li>Create a basic angular app using ng new angular-app</li><li>Add local-proxy.config.json file to target build files. Remember to keep the same port in config file as you did while running http-server</li></ol><pre>{<br>  &quot;/micro-frontend/main.js&quot;: {<br>    &quot;target&quot;: &quot;http://localhost:4202&quot;,<br>    &quot;secure&quot;: <em>false</em>,<br>    &quot;logLevel&quot;: &quot;debug&quot;,<br>    &quot;changeOrigin&quot;: <em>true</em>,<br>    &quot;pathRewrite&quot;: {&quot;^/micro-frontend&quot; : &quot;&quot;}<br>  }<br>}</pre><p>3. Add script tag inside index.html file in your angular app to point to your build file.</p><pre>&lt;script <em>type</em>=&quot;text/javascript&quot; <em>src</em>=&quot;/micro-frontend/main.js&quot;&gt;&lt;/script&gt;</pre><p>4. Now you can use the new html tag of your web-component and provide the correct input/ props.</p><pre>&lt;app-webcomponent <em>[data]</em>=&quot;data&quot;&gt;&lt;/app-webcomponent&gt;</pre><pre>private <em>readonly </em>data = [<br>  &quot;Fantastic Plastic Shoes&quot;,<br>  &quot;Fantastic Steel Car&quot;,<br>  &quot;Licensed Steel Gloves&quot;,<br>  &quot;Rustic Wooden Hat&quot;,<br>  &quot;Handmade Granite Chicken&quot;,<br>  &quot;Generic Rubber Sausages&quot;,<br>  &quot;Refined Granite Shoes&quot;,<br>  &quot;Rustic Wooden Computer&quot;,<br>  &quot;Licensed Rubber Chair&quot;,<br>  &quot;Refined Granite Car&quot;<br>];</pre><p>Success 🚀 We have achieved what we wanted! 🎉</p><p>Please let me know your feedback via 👏 or 📝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=515c2fed6a53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Front-end Development As An Absolute Beginner]]></title>
            <link>https://mtalham.medium.com/learn-front-end-development-as-an-absolute-beginner-3e7b544ba92d?source=rss-2e320cf066a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e7b544ba92d</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Talha Munir]]></dc:creator>
            <pubDate>Sat, 31 Oct 2020 20:59:06 GMT</pubDate>
            <atom:updated>2021-02-04T11:23:54.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*kqnFuEXi48_NgpvIpNsmDQ.jpeg" /></figure><p>If you want to learn web development where do you even start, it’s hard to find right advice without suffering from information overload. That’s why I am writing this beginners guide, all you need is the basic of web development and a general explanation with some direction on where to go next.</p><p>Here are the steps that you can follow as a beginner to become a front-end developer.</p><h3>Steps:</h3><ol><li>Basic concept of what is web development, how website works.</li><li>Difference between front-end vs back-end.</li><li>Usage of code editor</li><li>HTML, CSS</li><li>Javascript</li><li>Javascript frameworks</li><li>Package manager, build tools</li><li>Responsive design</li></ol><p>I would recommend to follow first five steps in order and last three steps can be done in any order. Now, let’s take a deep dive into these steps.</p><h3>How does website work:</h3><p>Basically website is just a bunch of files that are stored on a machine called a <strong><em>server</em></strong>. Server is connected to the internet and you can load that website through a browser like Chrome from any device (eg Computer, phone).</p><p>The person’s browser is called the <strong>client. </strong>Every time you are on the internet you (client) are getting data from the server and sending data back to server. There are tons of websites that are all made by web developers. It can be for a small business or a personal blog and it can be a complex web app like Twitter, AirBnb, Youtube or Facebook.</p><h3>Difference between Front-end &amp; Back-end:</h3><p>Frond-end and back-end define which part of the website you are working. <strong><em>Frond-end</em></strong> describe that you will be dealing mainly with the client side because it’s what user can see in the browser. On the other hand <strong><em>back-end</em></strong> is the part of the website which user cannot see but it handles mostly business logic, authentication and persistence of the data.</p><p>The best example to understand the difference is restaurant. Front-end web development is the section where customers can see and experience the restaurant like interior, seating and of course the food. Conversely, the back-end is the part where inventory and deliveries are managed and all the process to create the food.</p><p>Front-end and back-end web development serve differently but both are very important part of the website. If a person is involved in both front-end and back-end part of web development then it’s called full-stack developer.</p><h3>Code editors:</h3><p>The most essential tool that you will use while coding is the code editor or IDE (Integrated Development Environment). There are a lot of options but the most popular code editor amongst front-end developers is <a href="https://code.visualstudio.com/">VS Code</a>. It’s a more lightweight version of Visual Studio by Microsoft. It is fast, easy to use and the best part is that it is free 😉. You can customise it with themes and a lot of useful extensions that can increase your productivity as a web developer.</p><p>Other famous options include <a href="https://www.sublimetext.com/">Sublime text</a>, <a href="https://www.vim.org/download.php">Vim</a> and <a href="https://www.atom.io/">Atom</a>. But if you are just getting started then the best option in my opinion is VS Code.</p><h3>HTML/ CSS:</h3><p>HTML and CSS are almost always the first thing you wanted to learn in front-end development. HTML, or HyperText Markup Language, is the foundation of all websites. It’s the main file type that is loaded in your browser when you look at a website. CSS, or Cascading Style Sheets, lets you style that HTML content so it looks nice and fancy.</p><p>The main building blocks of HTML/ CSS are</p><ul><li>HTML5 (Semantic elements, attributes, doctype etc)</li><li>CSS (Colors, fonts and positioning)</li><li>CSS custom properties</li><li>CSS grid and Flexbox</li><li>CSS transitions</li></ul><h3>Javascript:</h3><p>JavaScript is a programming language that was designed to run in the browser. It is important to be able to make your website dynamic, meaning it will respond to different inputs from the user, or other sources.</p><p>The main building blocks of Javascript are</p><ul><li>Fundamentals (Variables, data types, functions, conditions etc)</li><li>JSON (Javascript Object Notation)</li><li>DOM (Document Object Model)</li><li>Fetch API</li><li>Modern JS (ES6)</li></ul><h3><strong><em>Resources To Learn HTML/CSS &amp; Javascript:</em></strong></h3><p>One of the best place I can recommend is <a href="https://www.freecodecamp.org/">freeCodeCamp</a>. It is an online coding bootcamp which is totally free. It’s the best option because if you are a beginner and not sure if coding is for you then you can try this without any risk to see if you like it.</p><p><a href="https://www.udemy.com/"><strong>Udemy</strong></a> is another great option. It is an online learning platform with a lot of great courses. Some of them are listed below:</p><p><a href="https://www.udemy.com/course/design-and-develop-a-killer-website-with-html5-and-css3/">Build Responsive Websites with HTML5 and CSS3</a></p><p><a href="https://www.udemy.com/course/the-complete-javascript-course/">The Complete JavaScript Course 2020: Build Real Projects!</a></p><p><a href="https://www.udemy.com/course/javascript-the-complete-guide-2020-beginner-advanced/">JavaScript — The Complete Guide 2020 (Beginner + Advanced)</a></p><p><strong>Youtube</strong> also offers tons of free video resources. Traversy Media is probably the best channel for beginners. <a href="https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ">FreeCodeCamp</a> also has their YouTube channel which contain some in-depth courses like <a href="https://www.youtube.com/watch?v=PkZNo7MFNFg&amp;ab_channel=freeCodeCamp.org">Learn JS for beginners</a>.</p><p>In addition there are some websites that have great articles and other resources</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Learn">MDN</a></li><li><a href="https://css-tricks.com/">CSS Tricks</a></li><li><a href="https://www.w3schools.com/">W3Schools</a></li></ul><h3>Front-end Framework (choose one):</h3><p>After learning the basics of vanilla javascript you may want to learn one of javascript frameworks. They allow you to build powerful single page applications with interactive UIs. There are three main choices:</p><p><a href="https://reactjs.org/docs/getting-started.html"><strong>React</strong></a>: Created by Facebook | most popular | fairly easy to learn</p><ul><li><a href="https://www.udemy.com/course/react-the-complete-guide-incl-redux/">React the complete guide</a> by Maximilian Schwarzmüller</li><li><a href="https://www.udemy.com/course/react-2nd-edition/">The complete react developer</a> by Andrew Mead</li></ul><p><a href="https://angular.io/start"><strong>Angular</strong></a>: Created by Google |used more in enterprise |steep learning curve</p><ul><li><a href="https://www.udemy.com/course/the-complete-guide-to-angular-2/">Angular — The complete guide</a> by Maximilian Schwarzmüller</li><li><a href="https://www.youtube.com/watch?v=_TLhUCjY9iA&amp;ab_channel=DesignCourse">Angular crash course</a> on YouTube</li></ul><p><a href="https://vuejs.org/v2/guide/"><strong>Vue</strong></a>: Created by Evan You | growing quickly | easiest to learn</p><ul><li><a href="https://www.youtube.com/watch?v=4deVCNJq3qc&amp;ab_channel=freeCodeCamp.org">Vue — Full course for beginners</a> on YouTube</li></ul><h3>Tools — Essential dev tools:</h3><p>In addition to above mentioned technologies there are some other tools that you may be working with as a front-end developer.</p><p><strong>Git (Version control) &amp; Github: </strong>Version control system keeps track of every code change that you make in your project files. <a href="https://git-scm.com/"><strong>Git</strong></a> is the most popular open source version control system. GitHub is owned by Microsoft which can be used to store all your Git repositories.</p><ul><li><a href="https://guides.github.com/">Online guides</a> from GitHub</li><li><a href="https://www.youtube.com/watch?v=SWYqp7iY_Tc&amp;ab_channel=TraversyMedia">Git crash course</a> by Traversy media</li></ul><p><strong>Package managers </strong>are online collection of software. They are like plugins that you can use in your project instead of writing them from scratch.</p><ul><li><a href="https://www.npmjs.com/">NPM</a> (node package manager)</li><li><a href="https://classic.yarnpkg.com/en/">Yarn</a></li></ul><p>Both are popular and good options. You can read more in the article called <a href="https://nodesource.com/blog/an-absolute-beginners-guide-to-using-npm/">An Absolute Beginner’s Guide to Using npm</a>.</p><p><strong>Build tools or JS module bundlers </strong>are tools front-end developers used to bundle JavaScript <strong>modules</strong> into a single JavaScript file that can be executed in the browser.</p><ul><li><a href="https://webpack.js.org/">Webpack</a> is very powerful bundler and it is used with JS frameworks.</li><li><a href="https://parceljs.org/">Parcel</a> is a new bundler and it comes with pre-configuration unlike webpack which require a lot of configuration.</li></ul><h3>Responsive design:</h3><p>Responsive design means that your styles look good on all devices. The core practices of responsive design include:</p><ul><li>Viewport</li><li>Media queries</li><li>Fluid widths</li><li>rem units over px</li><li>Mobile first</li></ul><p>For more detail on responsive design, check out this <a href="https://learn.shayhowe.com/advanced-html-css/responsive-web-design/"><strong>article</strong></a>.</p><p><a href="https://sass-lang.com/"><strong>Sass</strong></a><strong>: </strong>It’s an extension of CSS that makes CSS more efficient and adds more functionality to standard CSS. With Sass, you can create your own modular, reusable CSS components to use in your projects. You can learn more in this <a href="https://www.youtube.com/watch?v=Zz6eOVaaelI&amp;ab_channel=DevEd">video by Dev Ed</a>.</p><blockquote>Wow, that is a <strong>LOT</strong> to learn! But <strong>don’t try to learn everything at once</strong>, pick one skill at a time. Know that leaning web development is a <strong>long-term journey</strong> and just <strong>watching video of courses won’t make you an expert</strong>. Try to build actual websites and projects.</blockquote><p>I hope this guide helps you get started learning web development. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e7b544ba92d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Hook Forms — Managing Forms Efficiently at Scale]]></title>
            <link>https://mtalham.medium.com/react-hook-forms-managing-forms-efficiently-at-scale-d3ed36a1009f?source=rss-2e320cf066a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3ed36a1009f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[react-hook-form]]></category>
            <dc:creator><![CDATA[Talha Munir]]></dc:creator>
            <pubDate>Sun, 27 Sep 2020 15:34:27 GMT</pubDate>
            <atom:updated>2020-09-27T15:34:27.121Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Hook Forms — Managing Forms Efficiently at Scale</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqyRspx_5HOOieltIIzImw.jpeg" /></figure><p>Managing forms in React can easily become painful as your app scales. It could probably be due to the unorganised approach you followed while starting a project or writing the same boilerplate in every component or even sometimes applying hacks for tricky use cases. Speaking of the solutions, there are many form libraries out there and some of them handle forms really well but organising and keeping the code tidy is still up to you. In this article we’re going to solve this problem by building our form as simple as coding forms in vanilla HTML which can be used elegantly in any production app.</p><p>First list down some of the goals that we are trying to accomplish using react hook form.</p><ul><li><strong>Cutting down the boilerplate</strong> — we should be able to render the forms with clean and DRY code</li><li><strong>Validations</strong> — Perform simple and complex validations easily</li><li><strong>Flexibility</strong> — we should be able to put input fields at any level nested inside the form</li><li><strong>Accessibility</strong> — At the very basic level, the form elements should be easily accessible via keyboard</li><li><strong>Self detected submit button state</strong> — the button should automatically enable/disable or show loader as per the form state</li><li><strong>Performance</strong> — Last but not the least, it is crucial one especially when rendering large number of fields inside the form.</li></ul><p>To make things as clear as possible, we’ll make this simple code below render our form using <a href="https://react-hook-form.com/">React Hook Form</a>, a performant and easy to plug-in library for React forms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fEZR6gSQjMHGlLOQ8MEpiQ.png" /></figure><h3>Set up React app</h3><p>Let’s begin with setting up our react app by running npx create-react-app hooks-form &amp;&amp; yarn add react-hook-form</p><p>Next, we will create our reusable form and input components to cut down all the boilerplate.<br>React Hook Form provides us useForm and useFormContext hooks to get the form context right away and within the nested components respectively. We’ll be using both of these hooks for the communication between the form and input components.<br>First we’ll create the Form component followed by the input components such text fields, checkboxes, dropdown select, etc.</p><h3>Build the Form component</h3><p>We’ll initialise the form using useForm hook, and pass on all the methods as props to the form via FormProvider component. This will provide form state to the input components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4UxhFz_67yEj9c3qi_A8og.png" /></figure><h3>Build the form input elements</h3><p>Now that we have our Form component ready, we’ll create the form elements starting with the Input component.</p><h3>Input Component</h3><p>Since we don’t know how deeply we would nest the input components, we’ll use useFormContext to hook it up with its parent Form component that we created before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*UCHXQtzaC1fwm6dZ9h6lHA.png" /></figure><h3>Checkbox Component</h3><p>We’ll create the checkbox component the same way we did in the Input component, just adding type checkbox to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*tDDqsstOPMz0GIjVx7KoRA.png" /></figure><h3>Select Component</h3><p>This will be slightly different from the previous components as we’ll be using a 3rd party plugin for this. Keeping accessibility in mind, the best one I found is <a href="https://react-select.com/home">React Select</a>.<br>You can install the plugin using yarn add react-select and create the component as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxzylXGQfqmI3vuV4U7fhA.png" /></figure><h3>Submit Button Component</h3><p>The purpose of building the Button component is to make it handle enabled/disabled/loading state itself. Here, we’re simply disabling the button until the form fields are dirty or when the form is being submitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*f1EHHmni_l54e0Os109OZQ.png" /></figure><h3>Form Validation</h3><p>Till now, we have made our form functional and able to submit form data.<br>As our next requirement, we need to add validations to our form elements. We’ll allow two types of validations: one is to simply check if a required field is filled or not and other by providing a pattern to validate the value.<br>As an example, the Input component that we created before will now receive two extra props: required and validation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3PSh7lQwgLn5HWJ1UyMpxg.png" /></figure><p>The same way we can implement validation in our other components.</p><h3>Summing up</h3><p>In this article, we’ve created the components that are built on the basis of React Hooks with bare minimum code. If you wish to play around the code, here’s the <a href="https://github.com/mtalham/hooks-form">Github’s link</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3ed36a1009f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>