<?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 Charles Ketchasso on Medium]]></title>
        <description><![CDATA[Stories by Charles Ketchasso on Medium]]></description>
        <link>https://medium.com/@ketchasso72?source=rss-70e893acc68a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ZR_aCJIUxB5vNMRT</url>
            <title>Stories by Charles Ketchasso on Medium</title>
            <link>https://medium.com/@ketchasso72?source=rss-70e893acc68a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:11:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ketchasso72/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[Implementing client-side search in Next.js with Fuse.js]]></title>
            <link>https://medium.com/@ketchasso72/implementing-client-side-search-in-next-js-with-fuse-js-7bbf241b874f?source=rss-70e893acc68a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bbf241b874f</guid>
            <dc:creator><![CDATA[Charles Ketchasso]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 12:02:55 GMT</pubDate>
            <atom:updated>2023-07-10T12:02:55.152Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>The goal of this article is to share with everyone how to use fuse.js to handle text-search in your project.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KxySYHmTupZBuXjkb7ht6Q.jpeg" /></figure><p>Before we begin, let&#39;s define some terms. What is fuse.js?</p><p>Fuse.js is a powerful JavaScript library that enables fuzzy searching. Fuzzy search helps users find information even if they are unsure about the exact spelling or phrasing of what they are looking for. With Fuse.js, search queries can go beyond exact keyword matching to include approximate matching.</p><p>Enough of the talk, let&#39;s get into the exciting stuff.</p><p><strong>STEP 1: Setting up the Next application</strong></p><pre>npx create-next-app my-app</pre><p>The above command sets up a basic app structure that we can build upon to add our desired search functionality.</p><p>Next, navigate into the newly-created application folder and run the app by running the following in your terminal:</p><pre>cd my-app<br>npm run dev</pre><p>This will open the application in your browser as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zLEL3aiG5YHWEpWKZSR3Zg.png" /></figure><p>If the browser window doesn’t open automatically, navigate to <a href="http://localhost:3000/">http://localhost:3000/</a> to open your new web app.</p><h4>Step 2: Install Fuse.js</h4><p>Next, install Fuse.js by running the following in the root of your application directory:</p><pre>npm install fuse.js</pre><p>To use the Fuse.js library in our React app, we need to import the necessary components into the search.tsx file. This file will have been created automatically when you ran create-next-app above. Add the following imports within it:</p><pre>import Fuse from &quot;fuse.js&quot;;<br>import React, { useState } from &quot;react&quot;;<br></pre><h3>Step 3: Define searchable test data and relevant app states</h3><pre>const friends= [<br>  { name: &quot;John Doe&quot;, age: 25, email: &quot;johndoe@example.com&quot; },<br>  { name: &quot;Jane Doe&quot;, age: 30, email: &quot;janedoe@example.com&quot; },<br>  { name: &quot;Bob Smith&quot;, age: 35, email: &quot;bobsmith@example.com&quot; },<br>];<br><br>const [search, setSearch] = useState(friends)</pre><p>In a production application, this data will likely come from a database or some other source as opposed to being hard-coded, but we’re using an array here for illustrative purposes.</p><h3>Step 4: Set up the fuse.js Options</h3><pre> const fuse = new Fuse(friends, {<br>    keys: [&quot;name&quot;, &quot;email&quot;, &quot;age&quot;],<br>  });</pre><p>- keys is an array of strings that represent which object properties to search for matches. In this case, we’ll just search everything.</p><p>Well, there are many other options on fuse.js. for more info, you can use this: <a href="https://fusejs.io/api/options.html">Fuse.js Options</a>.</p><h3>Step 5: Handle search text input</h3><pre><br>const [input , setInput] = useState(&quot;&quot;)<br>// input getting text for search<br>&lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Search Messenger&quot;<br>        onChange={handleSearch}<br>      /&gt;<br><br></pre><p>The above code receive data from an input and send in a state.</p><h3>Step 8: Let’s combine code</h3><pre>&quot;use client&quot;<br>import React, { useState } from &quot;react&quot;;<br>import Fuse from &quot;fuse.js&quot;;<br>import &#39;./search.css&#39;<br>import friends from &quot;./freinds.json&quot;<br><br>export default function Search() {<br><br>  const [input, setInput] = useState&lt;any&gt;(friends);<br><br>  const handleSearch = (event:any) =&gt; {<br>    const { value } = event.target;<br>    if (value.length === 0) {<br>      setInput(friends);<br>      return;<br>    }<br><br>    const fuse = new Fuse(friends, {<br>      keys: [&quot;name&quot;, &quot;email&quot;, &quot;age&quot;],<br>    });<br><br>    const results = fuse.search(value);<br>    const items = results.map((result) =&gt; result.item);<br>    setInput(items);<br>  };<br><br> <br><br>  return (<br>    &lt;div&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        placeholder=&quot;Search Messenger&quot;<br>        onChange={handleSearch}<br>      /&gt;<br>      &lt;table&gt;<br>        &lt;thead&gt;<br>          &lt;tr&gt;<br>            &lt;th&gt;Name&lt;/th&gt;<br>            &lt;th&gt;Age&lt;/th&gt;<br>            &lt;th&gt;Email&lt;/th&gt;<br>          &lt;/tr&gt;<br>        &lt;/thead&gt;<br>        &lt;tbody&gt;<br>          {input?.map((person: any, index: any) =&gt; (<br>            &lt;tr key={index}&gt;<br>              &lt;td&gt;{person.name}&lt;/td&gt;<br>              &lt;td&gt;{person.age}&lt;/td&gt;<br>              &lt;td&gt;{person.email}&lt;/td&gt;<br>            &lt;/tr&gt;<br>          ))}<br>        &lt;/tbody&gt;<br>      &lt;/table&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Final output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgrbyFntNALGe7WihaPPcA.png" /></figure><p>Data found in the Database or JSON, but here for example purposes I am using JSON.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l3nb080g_Jpn2SzINfVcfg.png" /></figure><p>Real time search as you can see</p><h3>Conclusion</h3><p>Fuse.js is a powerful library that can enable real-time search in a React app, offering a better user experience and improved engagement.</p><p><strong>And that is it, guys! Enjoy your new search feature!</strong></p><p>Link to GitHub : <a href="https://github.com/kngcl/nextjs-search-fuse.js">next-search-fuse.js</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bbf241b874f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to handle forms in React, the easy way to do it]]></title>
            <link>https://medium.com/@ketchasso72/how-to-handle-forms-in-react-the-easy-way-to-do-it-8a6805c7c1d5?source=rss-70e893acc68a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6805c7c1d5</guid>
            <category><![CDATA[react-form-handling]]></category>
            <dc:creator><![CDATA[Charles Ketchasso]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 13:42:36 GMT</pubDate>
            <atom:updated>2023-06-30T13:42:36.367Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started using React, I learned how to manage forms. I learn about the <strong>CONTROLLED REACT FORM</strong> and <strong>UNCONTROLLED REACT</strong> FORM way of learning form handling in react. Use <strong>onChange</strong> handlers, and handle state in <strong>redux</strong>, handle state with<strong> useState</strong> or <strong>useReducer.</strong></p><p>Let’s make it simpler.</p><p>To start, let’s take the example of submitting and validating multi-field forms.</p><pre>function MyForm() {<br>  const [state, setState] = useState({ username: &#39;&#39;, age: null });<br><br>  const handleSubmit = (event) =&gt; {<br>    event.preventDefault();<br><br>    console.log(&#39;submitting&#39;, state);<br>  };<br><br>  const handleChange = (event) =&gt; {<br>    const name = event.target.name;<br>    const value = event.target.value;<br>    setState({ ...state, [name]: value });<br>  };<br><br>  return (<br>    &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;h1&gt;Hi!&lt;/h1&gt;<br><br>      &lt;p&gt;Enter your name:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;username&quot; onChange={handleChange} /&gt;<br><br>      &lt;p&gt;Enter your age:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;age&quot; onChange={handleChange} /&gt;<br><br>      &lt;br /&gt;&lt;br /&gt;<br>      &lt;input type=&quot;submit&quot; /&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>That is a lot of code to handle a form. Here we can see that with each keystroke (change) in the inputs, the status is updated. When a form is submitted, this status is read, validated and printed on the console.</p><p>Now let’s make this project smaller by eliminating all state management and change handlers.</p><pre>function MyForm() {<br>  return (  <br>    &lt;form&gt;<br>      &lt;h1&gt;Hi!&lt;/h1&gt;<br><br>      &lt;p&gt;Enter your name:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;<br><br>      &lt;p&gt;Enter your age:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;age&quot; /&gt;<br><br>      &lt;br /&gt;&lt;br /&gt;<br>      &lt;input type=&quot;submit&quot; /&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>Let’s say this is our form that we want to use to submit information</p><p>Firstly, let’s forget react, and try to recall how it would work without frameworks. So how do we read the values from this form using javascript? Once we have a reference to a form, with for example document.getElementById(‘form’), we can use FormData to read the form values.</p><pre>const element = document.getElementByID(&#39;form&#39;)<br>const data = new FormData(element);</pre><p>Now the data is of type FormData, so when you need an object that you can actually serialize(the process of converting object state into a format that can be transmitted or stored), you must first have it converted to a simple object. To do this, we use <strong>Object.fromEntries.</strong></p><p>Then we’ll put it all back together and create an onSubmit handler. Now, keep in mind that when a form is submitted, the form element is available under the <strong>event.currentTarget property</strong>. Snippet code below</p><pre>const handleSubmit = (event) =&gt; {<br>  event.preventDefault();<br><br>  const data = new FormData(event.currentTarget);<br>  const values = Object.fromEntries(data.entries());<br>  console.log(values);<br>};</pre><p>When we have all these parts together, we will have our final form of project as shown below.</p><pre>function MyForm() {<br>  const handleSubmit = (event) =&gt; {<br>    event.preventDefault();<br><br>    const data = new FormData(event.currentTarget);<br>    const values = Object.fromEntries(data.entries());<br><br>   console.log(&#39;submitting&#39;, values);<br>  };<br><br>  return (<br>    &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;h1&gt;Hi!&lt;/h1&gt;<br><br>      &lt;p&gt;Enter your name:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;<br><br>      &lt;p&gt;Enter your age:&lt;/p&gt;<br>      &lt;input type=&quot;text&quot; name=&quot;age&quot; /&gt;<br><br>      &lt;br /&gt;&lt;br /&gt;<br>      &lt;input type=&quot;submit&quot; /&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>No more state, no more change handler, just sending the form submission event, and working with simple HTML/javascript methods. No react particulars and no use of library other than native methods.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6805c7c1d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Month at Rebase Academy]]></title>
            <link>https://medium.com/@ketchasso72/my-first-month-at-rebase-academy-1d32a86a42ce?source=rss-70e893acc68a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d32a86a42ce</guid>
            <dc:creator><![CDATA[Charles Ketchasso]]></dc:creator>
            <pubDate>Fri, 11 Nov 2022 10:54:47 GMT</pubDate>
            <atom:updated>2022-11-23T21:50:12.853Z</atom:updated>
            <content:encoded><![CDATA[<p>Rebase is a programming school that trains children or students for one year. The languages taught are HTML, CSS, JavaScript, react. JS and node. JS.</p><p>I started the school on October 17, 2022, but before going to Rebase, I had worked as a technical guy in the company Vmedia, I decided to leave and sacrifice myself for a year to increase my knowledge in programming. That’s how my journey started.<br>I’ve been there for a month already and as far as my experience at the beginning of the journey, it wasn’t that waouh. I admit that what I expected was not really that. But as time went on, everything got better. What marked me during this first month is the patience with which the teachers teach, in this case Mr. Che Gaston a pro of programming he does not only program but knows how to make his children or students understand how to do it, when to do it. My week of HTML and CSS was also interesting, the different projects and everything. I really liked the last project, yes, yes I admit I learned while doing the Figma project. It was really a blend of precision, patience, determination, reflection and more.</p><p>Rebase, even though it’s new on the market. I might as well say this. You yes you who just left high school or just graduated and want to become a great developer. Rebase is for you. I’ve been there and so far I’m not disappointed with what I got. The month that starts, starts with JavaScript, a language that I really wanted to learn but for this programming language I reserve the surprise or my experience for the end of the JavaScript training.</p><p>To conclude, Rebase is a pretty good school.</p><p>The Rebase academy aims to put students on a tested and proven path to becoming world-class full-stack software engineers. All in the shortest amount of time possible, while preparing them for the job market. If this is what you are looking for, do what I did and check out the website at <a href="https://www.rebaseacademy.com/">https://www.rebaseacademy.com</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d32a86a42ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>