<?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 Aronmilahela on Medium]]></title>
        <description><![CDATA[Stories by Aronmilahela on Medium]]></description>
        <link>https://medium.com/@aronmilahela?source=rss-bedadabf4379------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lRO6wFZpGFvTfXEr</url>
            <title>Stories by Aronmilahela on Medium</title>
            <link>https://medium.com/@aronmilahela?source=rss-bedadabf4379------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:42:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aronmilahela/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[The biggest mistake we make with React tests]]></title>
            <link>https://medium.com/@aronmilahela/the-biggest-mistake-we-make-with-react-tests-debe449489a2?source=rss-bedadabf4379------2</link>
            <guid isPermaLink="false">https://medium.com/p/debe449489a2</guid>
            <dc:creator><![CDATA[Aronmilahela]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 14:42:19 GMT</pubDate>
            <atom:updated>2023-01-06T14:42:19.716Z</atom:updated>
            <content:encoded><![CDATA[<p>Testing React components is an important part of developing any application, as it helps to ensure that your code is working correctly and is of high quality. However, it is easy to make mistakes when writing tests for React components, and one of the biggest mistakes that we often make is not testing the component in isolation.</p><p>When testing a React component, it is important to test the component as a unit, rather than testing the component in the context of its children or the rest of the application. This is because the component should be able to stand on its own, and should not depend on the behavior of its children or the rest of the application in order to function correctly.</p><p>For example, consider the following simple React component:</p><pre>import React from &#39;react&#39;;</pre><pre>function MyComponent(props) {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{props.title}&lt;/h1&gt;<br>      &lt;p&gt;{props.description}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default MyComponent;</pre><p>This component simply renders a div element containing a h1 element with a title and a p element with a description. If we wanted to test this component, we might be tempted to write a test that renders the component in the context of a larger application, like this:</p><pre>import React from &#39;react&#39;;<br>import { render } from &#39;@testing-library/react&#39;;<br>import MyComponent from &#39;./MyComponent&#39;;</pre><pre>test(&#39;renders title and description&#39;, () =&gt; {<br>  const { getByText } = render(<br>    &lt;MyComponent title=&quot;Hello&quot; description=&quot;World&quot; /&gt;<br>  );</pre><pre>  const titleElement = getByText(/Hello/i);<br>  const descriptionElement = getByText(/World/i);</pre><pre>  expect(titleElement).toBeInTheDocument();<br>  expect(descriptionElement).toBeInTheDocument();<br>});</pre><p>This test will pass if the component is rendering the title and description correctly, but it does not test the component in isolation. The test is actually testing whether the component is rendering correctly in the context of the render function from @testing-library/react, which is not a true representation of how the component will be used in the real application.</p><p>To properly test the component in isolation, we can use a helper function like render from react-testing-library, which allows us to render the component on its own, without the context of the larger application. Here is an example of how we could rewrite the test to test the component in isolation:</p><pre>import React from &#39;react&#39;;<br>import { render } from &#39;react-testing-library&#39;;<br>import MyComponent from &#39;./MyComponent&#39;;</pre><pre>test(&#39;renders title and description&#39;, () =&gt; {<br>  const { getByText } = render(<br>    &lt;MyComponent title=&quot;Hello&quot; description=&quot;World&quot; /&gt;<br>  );</pre><pre>  const titleElement = getByText(/Hello/i);<br>  const descriptionElement = getByText(/World/i);</pre><pre>  expect(titleElement).toBeInTheDocument();<br>  expect(descriptionElement).toBeInTheDocument();<br>});</pre><p>This test will now properly test the component in isolation, and will ensure that the component is working correctly on its own, rather than relying on the behavior of its children or the rest of the application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=debe449489a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Touch less vending machining with react]]></title>
            <link>https://medium.com/@aronmilahela/vending-machining-payment-user-scan-qr-code-with-react-ceb02b032176?source=rss-bedadabf4379------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceb02b032176</guid>
            <dc:creator><![CDATA[Aronmilahela]]></dc:creator>
            <pubDate>Wed, 04 Jan 2023 10:54:16 GMT</pubDate>
            <atom:updated>2023-01-04T11:04:14.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U1lTct_1s_JrMp3Q.jpg" /></figure><p>Vending machines have come a long way since their inception. Gone are the days of having to carry around a pocket full of coins to make a purchase. Now, vending machine users have the option to pay with their phones using QR codes.</p><p>QR code payment options have become increasingly popular due to the convenience and speed of the transaction. To implement a QR code payment option in a vending machine, the machine will need to be equipped with a QR code scanner.</p><p>Once the QR code scanner is in place, users can simply open their phone’s payment app, scan the QR code displayed on the vending machine, and confirm the payment. The payment is then processed, and the vending machine dispenses the desired item.</p><p>Here is an example of how this process could be implemented using the React JavaScript library:</p><pre>import React, {useState} from &#39;react&#39;;</pre><pre>const VendingMachine = () =&gt; {<br>  const [paymentStatus, setPaymentStatus] = useState(null);</pre><pre>  const handleQRCodeScan = async () =&gt; {<br>    try {<br>      const paymentResult = await scanQRCode();<br>      if (paymentResult.success) {<br>        setPaymentStatus(&#39;success&#39;);<br>        dispenseItem();<br>      } else {<br>        setPaymentStatus(&#39;failure&#39;);<br>      }<br>    } catch (error) {<br>      setPaymentStatus(&#39;error&#39;);<br>    }<br>  }</pre><pre>  return (<br>    &lt;div&gt;<br>      {paymentStatus === &#39;success&#39; &amp;&amp; &lt;p&gt;Payment successful! Enjoy your item.&lt;/p&gt;}<br>      {paymentStatus === &#39;failure&#39; &amp;&amp; &lt;p&gt;Payment failed. Please try again.&lt;/p&gt;}<br>      {paymentStatus === &#39;error&#39; &amp;&amp; &lt;p&gt;An error occurred. Please try again.&lt;/p&gt;}<br>      {paymentStatus === null &amp;&amp; (<br>        &lt;button onClick={handleQRCodeScan}&gt;<br>          Scan QR code to make payment<br>        &lt;/button&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default VendingMachine;</pre><p>In this example, the VendingMachine component has a state variable called paymentStatus that is used to keep track of the status of the payment. When the user clicks the &quot;Scan QR code to make payment&quot; button, the handleQRCodeScan function is called. This function uses the scanQRCode function to scan the QR code and process the payment. If the payment is successful, the paymentStatus is updated to &#39;success&#39; and the vending machine dispenses the item. If the payment fails or an error occurs, the paymentStatus is updated accordingly.</p><p>This is just one example of how QR code payment could be implemented in a vending machine using React. There are many other ways this functionality could be implemented, and the specific implementation will depend on the requirements of the vending machine and the payment processing system being used.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ceb02b032176" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image segmentation]]></title>
            <link>https://medium.com/@aronmilahela/image-segmentation-f220beb6b079?source=rss-bedadabf4379------2</link>
            <guid isPermaLink="false">https://medium.com/p/f220beb6b079</guid>
            <dc:creator><![CDATA[Aronmilahela]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 09:02:31 GMT</pubDate>
            <atom:updated>2023-04-05T07:27:55.487Z</atom:updated>
            <content:encoded><![CDATA[<p>The &lt;map&gt; element in HTML is used to define a client-side image map, which is a set of coordinates that correspond to specific regions within an image. When the image is clicked, the user&#39;s browser will follow the link associated with the coordinates.</p><p>The &lt;area&gt; element is used within the &lt;map&gt; element to define the clickable areas within the image map. Each &lt;area&gt; element must have a shape attribute and a coords attribute, which define the shape and size of the clickable area.</p><p>In React, you can use the &lt;map&gt; and &lt;area&gt; elements just like any other HTML element. Here&#39;s an example of how you might use them in a React component:</p><pre>import React from &#39;react&#39;;</pre><pre>function ImageMap() {<br>  return (<br>    &lt;img src=&quot;/path/to/image.jpg&quot; useMap=&quot;#image-map&quot; alt=&quot;image with clickable areas&quot; /&gt;<br>    &lt;map name=&quot;image-map&quot;&gt;<br>      &lt;area shape=&quot;rect&quot; coords=&quot;0,0,82,126&quot; href=&quot;/path/to/link1&quot; alt=&quot;link1&quot; /&gt;<br>      &lt;area shape=&quot;circle&quot; coords=&quot;90,58,3&quot; href=&quot;/path/to/link2&quot; alt=&quot;link2&quot; /&gt;<br>      &lt;area shape=&quot;poly&quot; coords=&quot;188,61,215,62,215,34,224,34,224,62,251,62,251,50,236,49,236,57,251,57,251,47,266,47,266,61&quot; href=&quot;/path/to/link3&quot; alt=&quot;link3&quot; /&gt;<br>    &lt;/map&gt;<br>  );<br>}</pre><pre>export default ImageMap;</pre><p>This code is a React functional component that generates an HTML image with clickable areas. It defines a function called ImageMap that returns an image tag (&lt;img&gt;) and a map tag (&lt;map&gt;).</p><p>The &lt;img&gt; tag has the source (src) attribute set to a path to an image file (/path/to/image.jpg). The useMap attribute specifies the ID of the &lt;map&gt; tag that defines the clickable areas for the image. The alt attribute provides alternative text for the image, which is displayed if the image cannot be loaded.</p><p>The &lt;map&gt; tag has a name attribute set to &quot;image-map&quot;, which is the same ID used in the useMap attribute of the &lt;img&gt; tag. Inside the &lt;map&gt; tag, there are three clickable areas (&lt;area&gt; tags) defined.</p><p>Each &lt;area&gt; tag has a shape attribute that defines the shape of the clickable area (rect, circle, or poly for rectangle, circle, and polygon, respectively). The coords attribute specifies the coordinates of the clickable area. The href attribute provides the URL that the user will be directed to when they click on the area. The alt attribute provides alternative text for the clickable area, which is displayed if the image cannot be loaded.</p><p>Finally, the ImageMap function is exported as the default export of the module, which means it can be imported and used in other parts of the application.</p><p>Here is another example of a specified URL</p><pre>import React from &#39;react&#39;;</pre><pre>const ImageMap = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;img src=&quot;/image.png&quot; useMap=&quot;#image-map&quot; alt=&quot;A map of the United States&quot; /&gt;<br>      &lt;map name=&quot;image-map&quot;&gt;<br>        &lt;area shape=&quot;rect&quot; coords=&quot;0,0,82,126&quot; href=&quot;/texas&quot; alt=&quot;Texas&quot; /&gt;<br>        &lt;area shape=&quot;circle&quot; coords=&quot;90,58,3&quot; href=&quot;/oklahoma&quot; alt=&quot;Oklahoma&quot; /&gt;<br>        &lt;area shape=&quot;circle&quot; coords=&quot;124,58,8&quot; href=&quot;/kansas&quot; alt=&quot;Kansas&quot; /&gt;<br>      &lt;/map&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><pre>export default ImageMap;</pre><p>In this example, theimg tag renders an image of the map of the United States with a source file of &quot;/image.png&quot;. The useMap attribute links the image to the associated map tag with an ID of &quot;image-map&quot;. The alt attribute specifies alternative text for the image that will be displayed if the image fails to load.</p><p>The map the tag defines the clickable areas on the image. It has the name &quot;image-map,&quot; which is linked to the useMap attribute of the img tag.</p><p>Within the map tag, there are three area tags that define clickable regions on the image. The first area tag is a rectangle shape that corresponds to the state of Texas with coordinates (0,0,82,126). When this region is clicked, the user will be directed to the &quot;/texas&quot; URL, and the alt attribute provides alternative text for the region that will be displayed if the image fails to load.</p><p>Similarly, the second area tag is a circular shape that corresponds to the state of Oklahoma with coordinates (90,58,3). When this region is clicked, the user will be directed to the &quot;/oklahoma&quot; URL, and the alt attribute provides alternative text for the region.</p><p>Lastly, the third area tag is also a circular shape that corresponds to the state of Kansas with coordinates (124,58,8). When this region is clicked, the user will be directed to the &quot;/kansas&quot; URL, and the alt attribute provides alternative text for the region.</p><p>Overall, both code examples demonstrate how to create interactive maps or images with clickable regions using React functional components. These components can be used to create engaging user interfaces that provide useful information and enhance the user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f220beb6b079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pair Programming]]></title>
            <link>https://medium.com/@aronmilahela/pair-programming-eec5f4a5d186?source=rss-bedadabf4379------2</link>
            <guid isPermaLink="false">https://medium.com/p/eec5f4a5d186</guid>
            <category><![CDATA[pair-programming]]></category>
            <dc:creator><![CDATA[Aronmilahela]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 08:44:44 GMT</pubDate>
            <atom:updated>2023-01-02T08:44:44.985Z</atom:updated>
            <content:encoded><![CDATA[<p>Pair programming is a software development technique where two programmers work together at one workstation, with one person typing and the other person reviewing and providing feedback. This approach has several benefits, including increased productivity, better code quality, and an opportunity for team members to learn from each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2iAVmdOXYW25wLax0J9Bw.png" /></figure><p>One of the key advantages of pair programming is that it allows developers to share knowledge and skills. As one programmer writes code, the other can offer suggestions, ask questions, and point out potential issues. This helps to ensure that the final product is of high quality and meets the desired specifications.</p><p>Pair programming can also be a great way to increase productivity. By working together, two programmers can divide tasks and complete them more quickly than if they were working alone. In addition, pair programming allows developers to bounce ideas off each other, which can lead to more creative and efficient solutions.</p><p>If you’re considering implementing pair programming at your organization, there are a few things to keep in mind. First, it’s important to choose the right pair. Look for team members with complementary skills and experience, as well as a good working relationship. It’s also a good idea to establish clear goals and expectations for the pairing session, and to set aside dedicated time for programming together.</p><p>Overall, pair programming can be a valuable tool for improving code quality, increasing productivity, and fostering a culture of collaboration and learning within your team. So give it a try and see how it can benefit your organization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eec5f4a5d186" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>