<?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"><channel><title><![CDATA[Shareef]]></title><description><![CDATA[Shareef]]></description><link>https://shareef.hashnode.dev/</link><generator>RSS for Node</generator><lastBuildDate>Mon, 12 Oct 2026 09:40:17 GMT</lastBuildDate><atom:link href="https://shareef.hashnode.dev//rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to publish a CLI tool on NPM]]></title><description><![CDATA[Hello Developers 🙌🙌🙌
Recently I wanted to create a CLI tool, but I only know JavaScript, so I researched and found out that we can create CLI applications using JavaScript. I published my CLI tool named track-task and will show you how to publish ...]]></description><link>https://shareef.hashnode.dev//how-to-publish-a-cli-tool-on-npm</link><guid isPermaLink="true">https://shareef.hashnode.dev//how-to-publish-a-cli-tool-on-npm</guid><category><![CDATA[npm]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[ShowHashnode]]></category><category><![CDATA[Developer Tools]]></category><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Mon, 30 May 2022 15:29:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1653924414395/PEvgH5Ba-.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Hello Developers 🙌🙌🙌</strong></p>
<p>Recently I wanted to create a CLI tool, but I only know JavaScript, so I researched and found out that we can create CLI applications using JavaScript. I published my CLI tool named <em>track-task</em> and will show you how to publish a package in NPM. You can download and use it.</p>
<pre><code class="lang-npm">npm i -g track-task
</code></pre>
<h3 id="heading-how-to-publish-npm-package">How to publish NPM package?</h3>
<p><strong>Step 1:-</strong> Initialize <em>npm</em> by <code>npm init -y</code>
It will create a default package.json file, which will look something like</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"track-task"</span>,
  <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.0.0"</span>,
  <span class="hljs-attr">"description"</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">"main"</span>: <span class="hljs-string">"index.js"</span>,
  <span class="hljs-attr">"scripts"</span>: {
    <span class="hljs-attr">"test"</span>: <span class="hljs-string">"echo \"Error: no test specified\" &amp;&amp; exit 1"</span>
  },
  <span class="hljs-attr">"keywords"</span>: [],
  <span class="hljs-attr">"author"</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">"license"</span>: <span class="hljs-string">"ISC"</span>
}
</code></pre>
<p>Points to note here</p>
<ul>
<li>Name should be unique, otherwise it will throw error while publishing.</li>
<li>Start with version 1.0.0 and remember to update to version whenever you make changes to your code.</li>
<li>Add a bin as <code>" bin "./index.js"</code> from this point your code will run.</li>
<li>Add keywords and author name to stand out.</li>
</ul>
<p><strong>Step 2:-</strong> Code your application.
Code your whole application and test it out locally and make sure to add <code>#! /usr/bin/env node</code>, it makes your file executable.</p>
<p><strong>Step 3:-</strong> Add more info to package.json.
Add repository, bugs and homepage urls</p>
<pre><code class="lang-json">{
  ...
  <span class="hljs-attr">"repository"</span>: {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"git"</span>,
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"git+https://github.com/shareef99/task-tracker.git"</span>
  },
  <span class="hljs-attr">"bugs"</span>: {
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://github.com/shareef99/task-tracker/issues"</span>
  },
  <span class="hljs-attr">"homepage"</span>: <span class="hljs-string">"https://github.com/shareef99/task-tracker/#readme"</span>,
}
</code></pre>
<p><strong>Step 4:-</strong> Publishing your CLI tool</p>
<ul>
<li>Create <em>npm account</em>.</li>
<li>Login into npm account from terminal.<pre><code class="lang-npm">npm login
</code></pre>
</li>
<li>Enter the username and password.</li>
<li>Make sure you are ready to publish.</li>
<li>Publish your package.<pre><code class="lang-npm">npm publish
</code></pre>
</li>
</ul>
<p><strong><em>Congratulations ✨✨✨ You have published the npm package.</em></strong></p>
<p><strong>Step 5:-</strong> Updating package.
Don't forget to change the version of in package.json file after update your code. Once you are done with the coding, run <code>npm publish</code>.</p>
<p><strong>Thanks and Happy Coding</strong></p>
<p>Closing here 👋👋👋</p>
<blockquote>
<p>This is <strong>Shareef</strong>.
My <a target="_blank" href="https://portfolio.shareef.vercel.app/">Portfolio</a>
Twitter <a target="_blank" href="https://twitter.com/shareefBhai99">ShareefBhai99</a>
<a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a>
My <a target="_blank" href="https://dev.to/shareef">other Blogs</a></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Why I don't use LinkedIn and Why you should also!]]></title><description><![CDATA[Hello Developers 🖐🖐
In this article, I'm discussing why I don't use LinkedIn much and why you should also stop using it. LinkedIn is used by millions of humans, as I am a developer I can only write about the perspective of a developer. Disclaimer e...]]></description><link>https://shareef.hashnode.dev//why-i-dont-use-linkedin-and-why-you-should-also</link><guid isPermaLink="true">https://shareef.hashnode.dev//why-i-dont-use-linkedin-and-why-you-should-also</guid><category><![CDATA[LinkedIn]]></category><category><![CDATA[Blogging]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Wed, 04 May 2022 15:52:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1651673354973/BJ5qsRhVW.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Hello Developers 🖐🖐</strong></p>
<p>In this article, I'm discussing why I don't use LinkedIn much and why you should also stop using it. LinkedIn is used by millions of humans, as I am a developer I can only write about the perspective of a developer. Disclaimer everything in this article will be from the point of view of a developer.</p>
<h3 id="heading-why-you-should-have-a-linkedin-account">Why you should have a LinkedIn account.</h3>
<p>First and foremost, let's discuss why everybody tells you to have a LinkedIn account.</p>
<ul>
<li><strong>You will gain exposure to Hiring Managers and Recruiters</strong></li>
<li><strong>You will get offers from your LinkedIn profile.</strong></li>
<li><strong>You will get to know about Job Postings.</strong></li>
<li><strong>You can gain social proof of your skills and talents</strong></li>
<li><strong>LinkedIn can help rank your name on Google</strong></li>
</ul>
<p>These points seem fair and promising, but this is not the reality of LinkedIn today.</p>
<h3 id="heading-the-reality-check">The Reality Check 🙀 !</h3>
<p>It's all fake, fake, and fake. Yeah, you heard me right. It's all fake, what I see whenever I open my LinkedIn. MOTIVATION, Some random dude did some small thing and shared it by over-exaggeration, someone likes or comments on something, random job posting, which I would never apply to.</p>
<h3 id="heading-what-i-hate-about-linkedin">What I hate about LinkedIn</h3>
<ul>
<li><p>MOTIVATION, the number of motivational quotes that are there in my feed just makes me irritating. There are more people wanting to motivate than the number of people who want to get motivated.</p>
</li>
<li><p>Job alerts, I wonder who is posting tens of jobs on a daily basis. And the information about the job is useless. They want you to have the knowledge of all the programming languages from the time they are made 🙂🙂🙂. And the cherry on the cake it the pay range is not disclosed by the company. If the employers of LinkedIn read my blog (It will not reach them probably) please make the requirement limited and make the pay range mandatory.</p>
</li>
<li><p>Some likes or comments on something. For the sake of humanity I don't want to know what my connections are linking and commenting on, please just remove this feature or make it an optional feature so that people who want it can enable it (Hopefully no one wants to).</p>
</li>
<li><p>It's all fake. There is no measure to check if something is fake or not. For instance, I have added in my experience that I am working at Google as a Frontend Architecture from Jan 2020 and It is showing on my profile. Check it <a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">here</a>.</p>
</li>
<li><p>I could go on like this for hours, but I think you get my point.</p>
</li>
</ul>
<h3 id="heading-alternatives-of-linkedin">Alternatives of LinkedIn.</h3>
<ul>
<li>Github. Github is a great website to show your coding experience and your consistency through daily commits. However, it is only limited to developers.</li>
<li>Dev Community. Dev.to is a great blogging site, and I get plenty of offers from my Dev profile.</li>
<li>Hashnode. It is also a blogging site. It offers a lot of features free of cost.</li>
<li>Twitter. I don't promote Twitter as much as Github and Dev, but I would say it is better than LinkedIn.</li>
</ul>
<p>Let me know what are your thoughts, agree, or disagree. Let me know in the comments.</p>
<p>Closing here
This is <strong>shareef</strong></p>
<ul>
<li>My <a target="_blank" href="https://portfolio.shareef.vercel.app/">Portfolio</a></li>
<li>Twitter <a target="_blank" href="https://twitter.com/shareefBhai99">ShareefBhai99</a></li>
<li><a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Bye, Bye, Captcha!]]></title><description><![CDATA[A quick history about Captcha.
CAPTCHA is an abbreviation for Completely Automated Public Turing Test to Tell Computers and Humans Apart. Well, quite a long name. It was created to separate Bots from Humans. Initially, it was successful, but as human...]]></description><link>https://shareef.hashnode.dev//bye-bye-captcha</link><guid isPermaLink="true">https://shareef.hashnode.dev//bye-bye-captcha</guid><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Thu, 28 Apr 2022 09:46:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650629420259/CZa8LNhin.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-a-quick-history-about-captcha">A quick history about Captcha.</h3>
<p>CAPTCHA is an abbreviation for <strong>C</strong>ompletely <strong>A</strong>utomated <strong>P</strong>ublic <strong>T</strong>uring <strong>T</strong>est to <strong>T</strong>ell <strong>C</strong>omputers and <strong>H</strong>umans <strong>A</strong>part. <em>Well, quite a long name</em>. It was created to separate Bots from Humans. Initially, it was successful, but as humans fill in more and more Captchas, scammers use machine learning to catch up with the Captcha tests making captcha tests more difficult.</p>
<h3 id="heading-captcha-are-everywhere-on-the-internet">Captcha are everywhere on the internet.</h3>
<ul>
<li>Signup for any website. <strong>CAPTCHA</strong>!</li>
<li>Buying anything online. <strong>CAPTCHA</strong>!</li>
<li>Logging in on social media. <strong>CAPTCHA</strong>!</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650630544933/7421ckrXW.jpg" alt="captcha 4.jpg" /></p>
<h3 id="heading-well-now-say-bye-bye-to-captchas-and-welcome-to-2captchahttps2captchacom">Well, now say bye-bye to CAPTCHAs and welcome to <a target="_blank" href="https://2captcha.com/">2captcha</a></h3>
<p>2captcha is a service that bypasses captchas for you. They use humans to solve captchas. 2Captcha is a human-powered image and CAPTCHA recognition service. The main purpose of it is to solve CAPTCHAS in a quick and accurate manner by human employees so that customers get instant access to a website that they are trying to access.</p>
<h3 id="heading-human-powered-captcha-solving-service">Human-powered CAPTCHA-solving service</h3>
<p>2Captcha team solves your CAPTCHA with high accuracy. 
To start using the service:</p>
<ul>
<li>Register</li>
<li>Implement API</li>
<li>Send your CAPTCHAs</li>
<li>Get your answer as a text.</li>
</ul>
<p>It’s quick and easy! 2Captcha provides low prices and high accuracy for your CAPTCHAs.</p>
<h3 id="heading-2captcha-for-everyone">2Captcha for everyone.</h3>
<p>2Captcha service is not limited to customers. They provide APIs in most programming languages.
Developers can easily implement 2Chaptcha API in their applications.</p>
<p>There are a few steps for solving the captcha problem and they are as follows:</p>
<ul>
<li>simply send your image or captcha to their servers </li>
<li>Get the ID of your task by 2Captcha </li>
<li>Begin the cycle that checks if your task is completed.</li>
<li>Get the result instantly in mere just seconds.</li>
<li><a target="_blank" href="https://www.youtube.com/channel/UC_uHJbHt_zH89w4gKGC1sdw">Check out their YouTube channel</a></li>
<li><a target="_blank" href="https://akhromieiev.com/how-to-bypass-captcha-in-nodejs-using-2captcha/">Blogs on implementation of their API</a></li>
</ul>
<h3 id="heading-all-captchas-are-solved-here">All Captchas are solved here</h3>
<ul>
<li>Normal Captcha</li>
<li>Text Captcha</li>
<li>Click Captcha</li>
<li>Rotate Captcha</li>
<li>reCaptcha V2</li>
<li>And a lot more</li>
<li><a target="_blank" href="https://2captcha.com/">See all here</a></li>
</ul>
<h3 id="heading-let-money-decide">Let money decide</h3>
<p>Now you do know 2captcha is cool, but what about money? How much do you have to pay for 2Captcha services?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650638241371/-8Yb0nVMy.png" alt="image.png" /></p>
]]></content:encoded></item><item><title><![CDATA[The correct way of asking questions.]]></title><description><![CDATA[Hello Developers
I am an intermediate developer. I had great mentors to whom I could ask any question and they would help me. Now, as time passes I get many questions from the juniors, but I think they lack the ability to ask a question properly. Wel...]]></description><link>https://shareef.hashnode.dev//the-correct-way-of-asking-questions</link><guid isPermaLink="true">https://shareef.hashnode.dev//the-correct-way-of-asking-questions</guid><category><![CDATA[questions]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[mentorship]]></category><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Fri, 22 Apr 2022 15:43:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/KZcWygxZ_J4/upload/v1650642128943/r_MKrzMDk.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Hello Developers</strong></p>
<p>I am an intermediate developer. I had great mentors to whom I could ask any question and they would help me. Now, as time passes I get many questions from the juniors, but I think they lack the ability to ask a question properly. Well, you might ask who I am to lecture on this topic? I learned basically everything from asking questions and googling stuff.</p>
<h2 id="heading-try-to-google-before-asking-the-question">Try to google before asking the question.</h2>
<p>Google is an essential skill for any developer/programmer. Whenever you are struck first approve Google.</p>
<h3 id="heading-example">Example</h3>
<p>Before Googling</p>
<p><strong>You:</strong> How should I pass a child state to a parent state?.</p>
<p><strong>Mentor:</strong> Have you googled it?.</p>
<p><strong>You:</strong> No...</p>
<p>After Googling</p>
<p><strong>You:</strong> I am unable to pass child state to parent state. I googled it and it says [this] and [this].  </p>
<p><strong>Mentor:</strong> Okay, do [this] and refer to [this] article.</p>
<h2 id="heading-tell-us-the-real-problem">Tell us the real problem.</h2>
<p>Okay, let's say you are working on the front-end part of the project, and upon fetching data from the API you run into a CORS error. You google it and are still unable to solve it.</p>
<h3 id="heading-example">Example</h3>
<p>before not mentioning the real problem.</p>
<p><strong>You:</strong> I am trying to solve the CORS error and I did [this] and [this].</p>
<p><strong>Mentor:</strong> CORS are tricky. I can't exactly solve your problem.</p>
<p>After mentioning the real problem.</p>
<p><strong>You:</strong> While fetching the data from the API, I ran into a CORS error and I did [this] and [this].</p>
<p><strong>Mentor:</strong> Maybe the API is not handling requests properly. Submit the response and logs to the backend team.</p>
<h2 id="heading-some-tips">Some tips.</h2>
<ul>
<li>Try to solve before asking the question.</li>
<li>Google, Google, and Google.</li>
<li>Ask the real question, not the solution you are working on.</li>
<li>If you are stuck on a problem for too long, take a break.</li>
<li>And above all, ask the question.</li>
</ul>
<p><strong>HappyCoding</strong>
This is <a target="_blank" href="https://shareef.hashnode.dev/">Shareef</a>,
<a target="_blank" href="https://twitter.com/shareefBhai99">My Twitter</a>, and <a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">My Linkedin</a></p>
]]></content:encoded></item><item><title><![CDATA[Context API with TypeScript and Next.JS]]></title><description><![CDATA[Why do we need context?
In a typical React application, data is passed top-down (parent to child) via props. but such usage can be cumbersome for certain types of props (e.g., locale preference, UI theme) that are required by many components within a...]]></description><link>https://shareef.hashnode.dev//context-api-with-typescript-and-nextjs</link><guid isPermaLink="true">https://shareef.hashnode.dev//context-api-with-typescript-and-nextjs</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[Redux]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Wed, 20 Apr 2022 06:47:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650437056543/IKQGk0Nfx.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-why-do-we-need-context">Why do we need context?</h3>
<p>In a typical React application, data is passed top-down (parent to child) via props. but such usage can be cumbersome for certain types of props (e.g., locale preference, UI theme) that are required by many components within an application. Context provides a way to share values like these between components without having to explicitly pass a prop through every level of the tree. <a target="_blank" href="https://reactjs.org/docs/context.html">read more</a></p>
<h3 id="heading-what-is-contextapi">What is contextAPI?</h3>
<p>Context provides a way to pass data through the component tree without having to pass props down manually at every level.</p>
<p>So, now that we know why we need context and what context is, let's dive into the coding part.</p>
<p>Before starting, set up a basic version of the next JS app with typescript</p>
<pre><code class="lang-npm">npx create-next-app context-api
npm install --save-dev typescript @types/react
</code></pre>
<p>Create a folder called context, here we will store all the different contexts. For now, create an AuthContext.tsx file</p>
<h3 id="heading-step-1-create-context-type">Step 1:- Create context type</h3>
<p>Inside AuthContext.tsx.
As we are using TypeScript we have to create types for our context</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">type</span> authContextType = {
    user: <span class="hljs-built_in">boolean</span>;
    login: <span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">void</span>;
    logout: <span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">void</span>;
};
</code></pre>
<h3 id="heading-step-2-create-context-default-values">Step 2:- Create context default values</h3>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> authContextDefaultValues: authContextType = {
    user: <span class="hljs-literal">null</span>,
    login: <span class="hljs-function">() =&gt;</span> {},
    logout: <span class="hljs-function">() =&gt;</span> {},
};
</code></pre>
<h3 id="heading-step-3-createcontext-andamp-usecontext">Step 3:- createContext &amp; useContext</h3>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { createContext, useContext } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> AuthContext = createContext&lt;authContextType&gt;(authContextDefaultValues);

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">useAuth</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> useContext(AuthContext);
}
</code></pre>
<h3 id="heading-step-4-create-a-provider-function">Step 4:- Create a provider function</h3>
<pre><code class="lang-typescript"><span class="hljs-keyword">type</span> Props = {
    children: ReactNode;
};

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">AuthProvider</span>(<span class="hljs-params">{ children }: Props</span>) </span>{
    <span class="hljs-keyword">const</span> value = {

    }
    <span class="hljs-keyword">return</span> (
        &lt;AuthContext.Provider value={value}&gt;
            {children}
        &lt;/AuthContext.Provider&gt;
    );
}
</code></pre>
<p>We will wrap this AuthProvider function, where we want to use our context, and the value prop will have the values of authContextType. We will fill in the values in the next step.</p>
<h3 id="heading-step-5-fill-up-values">Step 5:- Fill up values</h3>
<pre><code class="lang-typescript"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">AuthProvider</span>(<span class="hljs-params">{ children }: Props</span>) </span>{
    <span class="hljs-keyword">const</span> [user, setUser] = useState&lt;<span class="hljs-built_in">boolean</span>&gt;(<span class="hljs-literal">null</span>);

    <span class="hljs-keyword">const</span> login = <span class="hljs-function">() =&gt;</span> {
        setUser(<span class="hljs-literal">true</span>);
    };

    <span class="hljs-keyword">const</span> logout = <span class="hljs-function">() =&gt;</span> {
        setUser(<span class="hljs-literal">false</span>);
    };

    <span class="hljs-keyword">const</span> value = {
        user,
        login,
        logout,
    };

    <span class="hljs-keyword">return</span> (
    ...
</code></pre>
<p>Now our context is ready to use.</p>
<h3 id="heading-step-6-enable-authprovider">Step 6:- Enable AuthProvider</h3>
<p>First, we have to enable AuthProvider, to do so edit the default _app.js file like so</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> { AuthProvider } <span class="hljs-keyword">from</span> <span class="hljs-string">"../context/AuthContext"</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">"../styles/globals.css"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyApp</span>(<span class="hljs-params">{ Component, pageProps }</span>) </span>{
    <span class="hljs-keyword">return</span> (
            &lt;AuthProvider&gt;
                &lt;Component {...pageProps} /&gt;
            &lt;/AuthProvider&gt;
    );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyApp;
</code></pre>
<p>Step 7:- Using context
Now remove all the template nextJS generate and simply import the context</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">import</span> Head <span class="hljs-keyword">from</span> <span class="hljs-string">"next/head"</span>;
<span class="hljs-keyword">import</span> styles <span class="hljs-keyword">from</span> <span class="hljs-string">"../styles/Home.module.css"</span>;
<span class="hljs-keyword">import</span> { useAuth } <span class="hljs-keyword">from</span> <span class="hljs-string">"../context/AuthContext"</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> { user, login, logout } = useAuth();

    <span class="hljs-keyword">return</span> (
        &lt;div className={styles.container}&gt;
            &lt;Head&gt;
                &lt;title&gt;Context-api <span class="hljs-keyword">with</span> TypeScript and nextJS&lt;/title&gt;
                &lt;link rel=<span class="hljs-string">"icon"</span> href=<span class="hljs-string">"/favicon.ico"</span> /&gt;
            &lt;/Head&gt;
            &lt;main className={styles.main}&gt;
                &lt;div&gt;
                    &lt;h1&gt;Hello Context&lt;/h1&gt;
                    &lt;h2&gt;User: {user ? <span class="hljs-string">"login"</span> : <span class="hljs-string">"logout"</span>}&lt;/h2&gt;
                    &lt;div&gt;
                        &lt;button onClick={login}&gt;Login&lt;/button&gt;
                        &lt;button onClick={logout}&gt;Logout&lt;/button&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/main&gt;
        &lt;/div&gt;
    );
}
</code></pre>
<p>Okay, many things happen here let me break it down, first, we import the context hook "useAuth" then inside our Home() we destructure all the values from "useAuth" then we use it as per our requirement.</p>
<p><a target="_blank" href="https://context-api-with-nextjs-and-ts.vercel.app/">See the live demo</a>
<a target="_blank" href="https://github.com/shareef99/context-api-with-nextjs-and-ts">Github repo</a>
<a target="_blank" href="https://portfolio.shareef.vercel.app/">My portfolio</a>
<a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a>
<a target="_blank" href="https://twitter.com/shareefBhai99">twitter</a></p>
]]></content:encoded></item><item><title><![CDATA[How to hide password value in inspect using React and Formik]]></title><description><![CDATA[Hello Developers 🤩🤩
Have you ever logged in to Facebook?
Have you ever inspected the Facebook login page?
If not go to Facebook and try inspecting it, you will find the value of the password filed is not showing.
We will replicate that behavior usi...]]></description><link>https://shareef.hashnode.dev//how-to-hide-password-value-in-inspect-using-react-and-formik</link><guid isPermaLink="true">https://shareef.hashnode.dev//how-to-hide-password-value-in-inspect-using-react-and-formik</guid><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Mon, 06 Dec 2021 16:56:04 GMT</pubDate><content:encoded><![CDATA[<p><strong>Hello Developers 🤩🤩</strong></p>
<p>Have you ever logged in to Facebook?
Have you ever inspected the Facebook login page?
If not go to <a target="_blank" href="https://www.facebook.com/">Facebook</a> and try inspecting it, you will find the value of the password filed is not showing.</p>
<p>We will replicate that behavior using React and Formik.</p>
<h3 id="heading-creating-project">Creating Project</h3>
<pre><code class="lang-npm">npx create-react-app my-app
</code></pre>
<p>After project setup, install formik.</p>
<pre><code class="lang-npm">npm install formik --save
</code></pre>
<h3 id="heading-basic-setup">Basic setup</h3>
<p>Setup a basic template for email and password input with submit button.</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { useFormik } <span class="hljs-keyword">from</span> <span class="hljs-string">"formik"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span> <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"email"</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> 
                <span class="hljs-attr">name</span>=<span class="hljs-string">"password"</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
                <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"password"</span>
            /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
    );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<h3 id="heading-implementing-formik">Implementing Formik</h3>
<pre><code class="lang-jsx"><span class="hljs-keyword">import</span> { useFormik } <span class="hljs-keyword">from</span> <span class="hljs-string">"formik"</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> handleSubmit = <span class="hljs-function">(<span class="hljs-params">values</span>) =&gt;</span> {
        <span class="hljs-built_in">console</span>.log(values);
    };

    <span class="hljs-keyword">const</span> formik = useFormik({
        <span class="hljs-attr">initialValues</span>: {
            <span class="hljs-attr">email</span>: <span class="hljs-string">""</span>,
            <span class="hljs-attr">password</span>: <span class="hljs-string">""</span>,
        },
    });

    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span>
            <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{(e)</span> =&gt;</span> {
                e.preventDefault();
                handleSubmit(formik.values);
            }}
        &gt;
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">"email"</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">"email"</span>
                <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"email"</span>
                {<span class="hljs-attr">...formik.getFieldProps</span>("<span class="hljs-attr">email</span>")}
            /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">"password"</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">"password"</span>
                <span class="hljs-attr">placeholder</span>=<span class="hljs-string">"password"</span>
                <span class="hljs-attr">onChange</span>=<span class="hljs-string">{formik.handleChange}</span>
                <span class="hljs-attr">onBlur</span>=<span class="hljs-string">{formik.handleBlur}</span>
            /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
    );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>Now check the value in Inspect.
<strong>Kaboom 🔥🔥🔥</strong>
No value in Inspect.</p>
<p><a target="_blank" href="https://39ph6.csb.app">Live Preview</a></p>
<p>Closing here 👋👋👋</p>
<blockquote>
<p><a target="_blank" href="https://github.com/shareef99/blogs/tree/master/hide-password-value">Github Code Repo</a>
This is <strong>Shareef</strong>.
My recent project <a target="_blank" href="https://yourounotes.vercel.app/">yourounotes</a>
My <a target="_blank" href="https://portfolio.shareef.vercel.app/">Portfolio</a>
Twitter <a target="_blank" href="https://twitter.com/shareefBhai99">ShareefBhai99</a>
<a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a>
My <a target="_blank" href="https://dev.to/shareef">other Blogs</a></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Convert Excel to JSON in ReactJS in just 2 steps]]></title><description><![CDATA[Hello Developers 🙌
Today we will see how to convert Excel to JSON
We will use xlsx package.
No more talking let's jump into the coding part.
Install xlsx package
npm i xlsx

Create a basic structure for file upload

<form>
    <label htmlFor="upload...]]></description><link>https://shareef.hashnode.dev//convert-excel-to-json-in-reactjs-in-just-2-steps</link><guid isPermaLink="true">https://shareef.hashnode.dev//convert-excel-to-json-in-reactjs-in-just-2-steps</guid><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Tue, 23 Nov 2021 15:20:54 GMT</pubDate><content:encoded><![CDATA[<p><strong>Hello Developers 🙌</strong></p>
<p>Today we will see how to convert Excel to JSON</p>
<p>We will use <code>xlsx</code> package.</p>
<p>No more talking let's jump into the coding part.</p>
<h3 id="heading-install-xlsx-package">Install <code>xlsx</code> package</h3>
<pre><code class="lang-npm">npm i xlsx
</code></pre>
<h3 id="heading-create-a-basic-structure-for-file-upload">Create a basic structure for file upload</h3>
<pre><code class="lang-html">
<span class="hljs-tag">&lt;<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"upload"</span>&gt;</span>Upload File<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
        <span class="hljs-attr">type</span>=<span class="hljs-string">"file"</span>
        <span class="hljs-attr">name</span>=<span class="hljs-string">"upload"</span>
        <span class="hljs-attr">id</span>=<span class="hljs-string">"upload"</span>
        <span class="hljs-attr">onChange</span>=<span class="hljs-string">{readUploadFile}</span>
    /&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
</code></pre>
<h3 id="heading-convert-excel-file-to-json">Convert Excel file to JSON</h3>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> readUploadFile = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
    e.preventDefault();
    <span class="hljs-keyword">if</span> (e.target.files) {
        <span class="hljs-keyword">const</span> reader = <span class="hljs-keyword">new</span> FileReader();
        reader.onload = <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
            <span class="hljs-keyword">const</span> data = e.target.result;
            <span class="hljs-keyword">const</span> workbook = xlsx.read(data, { <span class="hljs-attr">type</span>: <span class="hljs-string">"array"</span> });
            <span class="hljs-keyword">const</span> sheetName = workbook.SheetNames[<span class="hljs-number">0</span>];
            <span class="hljs-keyword">const</span> worksheet = workbook.Sheets[sheetName];
            <span class="hljs-keyword">const</span> json = xlsx.utils.sheet_to_json(worksheet);
            <span class="hljs-built_in">console</span>.log(json);
        };
        reader.readAsArrayBuffer(e.target.files[<span class="hljs-number">0</span>]);
    }
}
</code></pre>
<p>Kaboom!🔥 in just two simple steps, you can convert Excel to JSON</p>
<p><strong>HappyCoding</strong></p>
<p>Closing here 👋👋👋</p>
<blockquote>
<p>This is <strong>Shareef</strong>.
My recent project <a target="_blank" href="https://yourounotes.vercel.app/">yourounotes</a>
My <a target="_blank" href="https://portfolio.shareef.vercel.app/">Portfolio</a>
Twitter <a target="_blank" href="https://twitter.com/shareefBhai99">ShareefBhai99</a>
<a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a>
My <a target="_blank" href="https://dev.to/shareef">other Blogs</a></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Rendering markdown made easy with react-markdown
in ReactJS and NextJS web APPs]]></title><description><![CDATA[Hello Developers 👋
If you are using ReactJS or NextJS(React Framework) to make your blog then rendering MARKDOWN is so much easy with React-Markdown

React-Markdown comes with build-in TypeScript support 🤩.
Let's stop talking and start coding.

Bas...]]></description><link>https://shareef.hashnode.dev//rendering-markdown-made-easy-with-react-markdown-in-reactjs-and-nextjs-web-apps</link><guid isPermaLink="true">https://shareef.hashnode.dev//rendering-markdown-made-easy-with-react-markdown-in-reactjs-and-nextjs-web-apps</guid><dc:creator><![CDATA[Nadeem Shareef]]></dc:creator><pubDate>Thu, 13 May 2021 14:15:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650563846754/lI1l15_FY.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-hello-developers">Hello Developers 👋</h1>
<p>If you are using ReactJS or NextJS(React Framework) to make your blog then rendering <strong>MARKDOWN</strong> is so much easy with <strong>React-Markdown</strong></p>
<blockquote>
<p>React-Markdown comes with build-in <strong>TypeScript</strong> support 🤩.
Let's stop talking and start coding.</p>
</blockquote>
<h2 id="heading-basic-setup">Basic setup</h2>
<ul>
<li>I am using <strong>NextJS</strong> with <strong>TypeScript</strong> for this blog.</li>
<li>I have a folder/directory with the name <em>post</em> containing all the posts and inside the <em>post</em> folder/directory I have two posts.</li>
<li>You can find the code on my GitHub (Link will be shared at the end).</li>
</ul>
<pre><code class="lang-tsx">// pages/index.tsx
import { FC, Fragment } from "react";
import Link from "next/link";

interface Props {}

const Home: FC&lt;Props&gt; = () =&gt; (
    &lt;Fragment&gt;
        &lt;h1&gt;Hello Next.js 👋&lt;/h1&gt;
        &lt;div className="posts-container"&gt;
            &lt;Link href="/posts/first-post"&gt;First post&lt;/Link&gt;
            &lt;Link href="/posts/second-post"&gt;Second post&lt;/Link&gt;
        &lt;/div&gt;
    &lt;/Fragment&gt;
);

export default Home;
</code></pre>
<ul>
<li>I am keeping things simple to focus more on <strong>React-Markdown</strong></li>
</ul>
<blockquote>
<p>These two posts are taken from <strong><a target="_blank" href="https://twitter.com/maxedapps">Maximilian</a></strong> course on <strong>NextJS</strong></p>
</blockquote>
<ul>
<li>Then we have a file to show individual posts and render our <strong>MARKDOWN</strong></li>
</ul>
<pre><code class="lang-tsx">// /pages/posts/[slug].tsx

import { FC, Fragment } from "react";
import { GetStaticProps, GetStaticPropsContext, GetStaticPaths } from "next";
import { PostType } from "../../interfaces";
import { getPostData, getPostsFiles } from "../../lib/post-utils";
import PostContent from "../../components/PostContent";

interface Props {
    post: PostType;
}

const BlogPost: FC&lt;Props&gt; = ({ post }: Props) =&gt; {
    return (
        &lt;Fragment&gt;
            // /components/PostContent.tsx
            &lt;PostContent post={post} /&gt;
        &lt;/Fragment&gt;
    );
};

export const getStaticProps: GetStaticProps = async (context: GetStaticPropsContext) =&gt; {
    const { slug } = context.params;
    const postData = getPostData(slug);
    return {
        props: {
            post: postData,
        },
        // regenerate after every 600s(10mins)
        revalidate: 600,
    };
};

export const getStaticPaths: GetStaticPaths = async () =&gt; {
    const postFilenames = getPostsFiles();
    const slugs = postFilenames.map((fileName) =&gt;
        fileName.replace(/\.md$/, "")
    );
    return {
        paths: slugs.map((slug) =&gt; ({ params: { slug: slug } })),
        fallback: false,
    };
};

export default BlogPost;
</code></pre>
<blockquote>
<p>Here I set up the basic /posts/[slug] page, I will not go into details, let's Work on the <strong>PostContent</strong> component</p>
</blockquote>
<h2 id="heading-lets-work-with-react-markdown">Let's work with React-Markdown.</h2>
<ul>
<li>Install <em>React-Markdwon</em><pre><code class="lang-npm">   npm i react-markdown
</code></pre>
<blockquote>
<p>Now the easiest way to render <strong>MARKDOWN</strong></p>
</blockquote>
</li>
</ul>
<pre><code class="lang-tsx">
import React from "react";
import { PostType } from "../interfaces";
import ReactMarkdown from "react-markdown";

interface Props {
    post: PostType;
}

const PostContent = ({ post }: Props) =&gt; {
    return (
        &lt;article className="content"&gt;
            &lt;ReactMarkdown&gt;{post.content}&lt;/ReactMarkdown&gt;
        &lt;/article&gt;
    );
};

export default PostContent;
</code></pre>
<blockquote>
<p>Wooowww! with just one line we render <strong>MARKDOWN</strong>
But if we go to the first blog it doesn't show an image because we get only the name of the file, we have to generate the path for the image and we can also customize how an image should display.</p>
</blockquote>
<h2 id="heading-lets-optimize-andamp-customize-the-image">Let's optimize &amp; customize the image.</h2>
<ul>
<li>ReactMarkdown has <strong>components</strong> prop which help us to map tag name to React Component</li>
<li><strong>components</strong> take an object which contains the mapping of HTML tags.</li>
</ul>
<blockquote>
<p>Here, we are checking if a <strong>P</strong> tag has an image element if yes, then we are rendering our own image with our custom styles and if it is not an image then we are just returning the content of it.</p>
</blockquote>
<pre><code class="lang-tsx">
...
const PostContent = ({ post }: Props) =&gt; {
    return (
        &lt;article className="content"&gt;
            &lt;ReactMarkdown
                components={{
                    p: ({ node, children }) =&gt; {
                        if (node.children[0].tagName === "img") {
                            const image: any = node.children[0];
                            return (
                                &lt;div className="image"&gt;
                                    &lt;Image
                                        src={`/images/${image.properties.src}`}
                                        alt={image.properties.alt}
                                        width="600"
                                        height="300"
                                    /&gt;
                                &lt;/div&gt;
                            );
                        }
                        // Return default child if it's not an image
                        return &lt;p&gt;{children}&lt;/p&gt;;
                    },
                }}
            &gt;
                {post.content}
            &lt;/ReactMarkdown&gt;
        &lt;/article&gt;
    );
};
</code></pre>
<h2 id="heading-lets-add-syntax-highlighting-for-code-blocks">Let's add syntax highlighting for <em>CODE</em> blocks</h2>
<ul>
<li>Firstly install syntax-highlighter<pre><code>npm i react<span class="hljs-operator">-</span>syntax<span class="hljs-operator">-</span>highlighter @types<span class="hljs-operator">/</span>react<span class="hljs-operator">-</span>syntax<span class="hljs-operator">-</span>highlighter
</code></pre></li>
<li>react-syntax-highlighter makes it very easy to style our <strong>CODE</strong> blocks.</li>
<li>Here I am using 'materialDark' but you have many options and many themes to apply for your site.</li>
</ul>
<pre><code class="lang-tsx">
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { materialDark } from "react-syntax-highlighter/dist/cjs/styles/prism";

const PostContent = ({ post }: Props) =&gt; {
    return (
        &lt;article className="content"&gt;
            &lt;ReactMarkdown
                components={{
                    p: ({ node, children }) =&gt; {
                        ...
                    },
                    code({ className, children }) {
                        // Removing "language-" because React-Markdown already added "language-"
                        const language = className.replace("language-", "");
                        return (
                            &lt;SyntaxHighlighter
                                style={materialDark}
                                language={language}
                                children={children[0]}
                            /&gt;
                        );
                    },
                }}
            &gt;
                {post.content}
            &lt;/ReactMarkdown&gt;
        &lt;/article&gt;
    );
};
</code></pre>
<p>Closing here 👋👋👋</p>
<blockquote>
<p>This is <strong>Shareef</strong>.
My <a target="_blank" href="https://portfolio.shareef.vercel.app/">Portfolio</a>
Twitter <a target="_blank" href="https://twitter.com/shareefBhai99">ShareefBhai99</a>
<a target="_blank" href="https://github.com/shareef99/blogs/tree/master/markdown">GitHub repo of this blog</a>
<a target="_blank" href="https://www.linkedin.com/in/nadeem-shareef-7a8394182/">Linkedin</a>
My <a target="_blank" href="https://dev.to/shareef">other Blogs</a></p>
<p>Cover photo by [Dustin Curtis] (https://github.com/dcurtis/markdown-mark/tree/master/svg)</p>
</blockquote>
]]></content:encoded></item></channel></rss>