<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aadi</title>
    <description>The latest articles on Forem by Aadi (@exploreraadi).</description>
    <link>https://forem.com/exploreraadi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F363839%2Fae31a98a-175a-4524-b77d-0ed0654d01af.jpeg</url>
      <title>Forem: Aadi</title>
      <link>https://forem.com/exploreraadi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/exploreraadi"/>
    <language>en</language>
    <item>
      <title>A step by step guide to publish your first react library on npm.</title>
      <dc:creator>Aadi</dc:creator>
      <pubDate>Sun, 21 Feb 2021 14:27:48 +0000</pubDate>
      <link>https://forem.com/exploreraadi/a-step-by-step-guide-to-publish-your-first-react-library-on-npm-l0l</link>
      <guid>https://forem.com/exploreraadi/a-step-by-step-guide-to-publish-your-first-react-library-on-npm-l0l</guid>
      <description>&lt;p&gt;In this article, I will go through the entire process of creating a reusable component and publishing it on npm for other developers to use.&lt;/p&gt;

&lt;p&gt;This article assumes that you already have a component to publish but if you don't then just create a simple button component or something to test your understanding once you finish reading this. I have tried to keep this article easy to follow for beginners with less technical jargons to help you quickly launch your package so let's get started.&lt;/p&gt;

&lt;p&gt;Firstly, &lt;strong&gt;what is a reusable component?&lt;/strong&gt;&lt;br&gt;
I will use an interesting analogy to make sure you never have to look up for its definition again.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Imagine a pond of water with a caretaker whose only job is to help people catch fishes easily from the pond or dump their wastes into it. A reusable component is just like that pond and the caretaker is our props, the fishes coming out of the pond or the waste going into it is the data that we pass or fetch using props. That's it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now I will take you through the steps involved in this whole process. These are the steps that I created for myself while planning for the project and I urge everyone working on their projects to first think about the whole process and break it down into small steps because that will help you measure your progress as well as boost your morale as you move forward. I consider programming as no less than a battlefield and it is very easy to drop your weapons and surrender here when things get rough, especially when you are a beginner. That's why having checkpoints in your path is important. Let's move onto the steps now:&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the component:
&lt;/h3&gt;

&lt;p&gt;The first part is to actually write the code for the component and test it out. My first npm package was a simple drag and drop component and since it was not a lot of work as I just needed few event listeners to listen for drag and drop event and then callbacks to handle those events, I went ahead to write a sample code with &lt;a href="https://codesandbox.io/"&gt;codesandbox&lt;/a&gt;. It is a great tool if you want to avoid the hassle of creating react boilerplates just to create and test a simple component. But if you want to use your code editor from the beginning then I would need you to first create a react boilerplate then a folder named "component" in the src directory and put your component code in it. Then clean your parent component (the app.js file in src) and import the component you created. Check if it is working as expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Passing data:
&lt;/h3&gt;

&lt;p&gt;The next step was to think about how I would receive some data from the user. I am sure you already know how to do that. Yes, I am talking about props but we don't simply use that here as we do normally in our projects. We first import a package called &lt;a href="https://www.npmjs.com/package/prop-types"&gt;prop-types&lt;/a&gt; to declare the types of props that will be passed in  our component. Here is how I used it in my component to give you an idea. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sxeSTqHw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efgurzuazhp0me1pquay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sxeSTqHw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efgurzuazhp0me1pquay.png" alt="sample-code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are familiar with typescript then you might already understand what I did here. Typechecking your props like this makes sure that only the data-type you declared can be passed as props else will throw an error in the developer's console.&lt;br&gt;
This is helpful because suppose you built a big and complex library but those who are using it in their projects don't know the data-type they are supposed to pass as props and hence might pass the wrong ones making your library to behave unexpectedly while they won't know what they did wrong (Example- Your library expected a string as props but received an object instead). Here's a great &lt;a href="https://medium.com/@stevenpaulino1/typechecking-with-react-proptypes-6c8f46d78b8a#:~:text=Props%20are%20vital%20for%20passing,behave%20as%20expected%20or%20effectively."&gt;article&lt;/a&gt; if you're interested to learn more about prop-types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fetching data:
&lt;/h3&gt;

&lt;p&gt;Now comes the third part which is fetching data from the library i.e. returning some data to the user. In my drag and drop files, I had to return the dropped files and believe me, despite being so simple, it took me a while to realize because I thought there might be some other magic trick to do that but there wasn't. I just had to pass a callback as props to my component the way we normally do anywhere in react which will carry the data back to the parent. simple, right? So if you scroll back to the code in the image above, you'll see that I am receiving a callback as a prop named &lt;em&gt;getFiles&lt;/em&gt; for the same. One more thing, that &lt;em&gt;isRequired&lt;/em&gt; at the end in our propTypes is added to indicate that without passing that prop, our component won't work as expected. There are other props that are passed as optional in which case, you don't need to add &lt;em&gt;isRequired&lt;/em&gt; in the end when declaring their types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Publishing the component:
&lt;/h3&gt;

&lt;p&gt;The last step is to actually minify the code to publish but since I had little idea about webpack or anything, I followed &lt;a href="https://medium.com/groftware/how-to-publish-your-react-component-on-npm-9cf48d91944d"&gt;this article&lt;/a&gt; by Chan. It gives you a boilerplate with all the fine tuning already done to the files to publish on npm. Just replace the src files with yours, change the project name in package.json and webpack, create a build and publish it. Volla! easy peasy. I know you might be wondering, "But this is like a shortcut, where are the detailed steps for publishing?" and you are right but my friend if you're publishing a package or building any new kind of project for the first time then your primary goal should be just completing it as soon as you can. Remember I earlier mentioned that programming is no less than a battlefield and in a battlefield, winning with minimum casualties is the primary goal. And that was our motive too in this article, to complete and publish our library without dying i.e. loosing motivation in the middle. You can always go and dive deep into publishing a package or what goes under the hood when npm publishes our package? how does webpack work? etc. But for now, this is enough.&lt;/p&gt;

&lt;p&gt;And if you continued this far then here is a bonus. In the image I shared above, you will see I imported something called &lt;em&gt;useDropy&lt;/em&gt; but what is that? They are called &lt;strong&gt;custom hooks&lt;/strong&gt; in React (give yourselves a pat on your back if you already knew). Let me explain what this is with a simple example. Take any of your component files and instead of returning the JSX at the end, return some value like you do in a normal JavaScript function and that's it, that has now become a custom hook which can be imported anywhere in your project to fetch that data being returned. In react's language, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Building your own Hooks lets you extract component logic into reusable functions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That can save you from the pain of prop-drilling and will help you keep your code clean. You can read more about them &lt;a href="https://reactjs.org/docs/hooks-custom.html"&gt;here.&lt;/a&gt; &lt;br&gt;
To checkout my first drag and drop library that I published on npm, &lt;a href="https://www.npmjs.com/package/dropy"&gt;click here&lt;/a&gt;.&lt;br&gt;
I hope you liked the article, wish you all the best.&lt;/p&gt;

</description>
      <category>node</category>
      <category>codenewbie</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Mysterious React hook: useRef() </title>
      <dc:creator>Aadi</dc:creator>
      <pubDate>Mon, 21 Sep 2020 02:33:22 +0000</pubDate>
      <link>https://forem.com/exploreraadi/the-mysterious-react-hook-useref-4lj4</link>
      <guid>https://forem.com/exploreraadi/the-mysterious-react-hook-useref-4lj4</guid>
      <description>&lt;p&gt;&lt;strong&gt;useRef()&lt;/strong&gt; hook is used to create references (or refs in short) in functional components of React.&lt;br&gt;
Yes, that’s it, you can stop reading now (just kidding). &lt;/p&gt;

&lt;p&gt;In this article, I’ll briefly explain what a &lt;strong&gt;Ref&lt;/strong&gt; is, what it can do and how to use it without making it much complex.&lt;/p&gt;

&lt;p&gt;As per the definition from Reactjs official docs,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Refs provide a way to access DOM nodes or React elements created in the render method.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the best definition anyone can give about refs but let me put it even more simply. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Refs let you target any HTML or React element just like the &lt;em&gt;id&lt;/em&gt; attributes. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Though refs are slightly different and more convenient in some cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now Let’s see where to assign ref and how does the &lt;strong&gt;useRef&lt;/strong&gt; hook helps us:&lt;br&gt;
As I said earlier, it works like ids so you can put it in a div element like the ids: &lt;code&gt;&amp;lt;div ref={myTarget} /&amp;gt;&lt;/code&gt; but why am I using curly brackets instead of strings like we use while assigning ids to elements: &lt;code&gt;&amp;lt;div id='mytarget' /&amp;gt;&lt;/code&gt;?&lt;br&gt;
The reason is self-explanatory, we are passing that &lt;em&gt;myTarget&lt;/em&gt; as a variable into the ref. This variable is like a name to that particular div element and will help us target it later. Now you might ask that we haven’t defined any variable named &lt;em&gt;myTarget&lt;/em&gt; then what are we passing? &lt;br&gt;
Well then let’s define that variable but a little trick here. You cannot just define any variable and pass it to ref (like const ref = something) because when we pass a variable to ref, it needs to be created specially just to be used in ref. But how do we create a special variable like that? This is where the hook &lt;strong&gt;useRef&lt;/strong&gt; comes in. We use this hook to create our special variable and also assign it an initial value of null as shown in the image. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have created our ref, time to use it:&lt;br&gt;
To target our beloved element, we use a property called &lt;em&gt;current&lt;/em&gt; which acts like an indicator or a signal that tells us whether our targeted element is painted (or loaded) in the DOM or not. We will add an if else condition in useEffect to check that and then do whatever magic we want.&lt;br&gt;
There are a bunch of things you can do after targeting an element once the DOM loads like adding some animation to that element or if it is an input element then you can add a property called &lt;em&gt;focus&lt;/em&gt; to it and it will focus on that input. This comes handy when you want a user to navigate to a form to fill their names once they visit your website or something else. You can also use many third party libraries in it. Here is an image showing the code for whatever I've explained so far.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcfx0xxjvezztce7cf3i7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcfx0xxjvezztce7cf3i7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope this article helped you understand the use of ref attribute and &lt;strong&gt;useRef&lt;/strong&gt; hook in React. I am leaving some links down here in case you want to explore more. &lt;br&gt;
Happy Coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/refs-and-the-dom.html" rel="noopener noreferrer"&gt;Reactjs docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://css-tricks.com/working-with-refs-in-react/" rel="noopener noreferrer"&gt;CSS-tricks article&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>How to deploy web apps as a beginner ?</title>
      <dc:creator>Aadi</dc:creator>
      <pubDate>Sun, 02 Aug 2020 04:29:41 +0000</pubDate>
      <link>https://forem.com/exploreraadi/how-to-deploy-web-apps-as-a-beginner-456o</link>
      <guid>https://forem.com/exploreraadi/how-to-deploy-web-apps-as-a-beginner-456o</guid>
      <description>&lt;p&gt;Did you recently start learning web development and made your first or second web app but are now confused about how and where would you deploy it?&lt;br&gt;
Then this article is for you.&lt;/p&gt;

&lt;p&gt;I have tried to keep this extremely short to let you know just enough to get started quickly as I too understand the excitement of hosting your first few projects on the web.&lt;br&gt;
Though there are tons of options out there ( both free and paid ) still we will be mainly looking at the two most popular and free ones:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Heroku – It is a platform that lets developers deploy, manage, scale web apps. It provides its own CLI which lets you use your terminal to track changes or deploy your code directly to Heroku after logging in. They provide a detailed and step by step guide for beginners as soon as you sign up and set up your account.&lt;br&gt;
But if you still want to read their documentation in detail then click &lt;a href="https://devcenter.heroku.com/articles/"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Vercel – Vercel is also a platform to deploy and manage your web apps but the front-end part only. Though the steps are very easy. You just need to connect your Github account with Vercel and then choose the repository which has the project you wish to deploy. Once added, it will also keep track of any changes you’ll do in your master branch and will keep re-deploying the app with those changes. Just visit &lt;a href="https://vercel.com/"&gt;Vercel&lt;/a&gt; and follow the steps.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After looking at the options, let us look at their use cases.&lt;br&gt;
I use Heroku to launch my node apps or any other backend I build and Vercel for my static sites or front-end of my apps.&lt;br&gt;
Now, if you’re looking to deploy a Fullstack app you might ask, “Why to deploy the front-end and backend separately? Why not host everything in one place ?”&lt;/p&gt;

&lt;p&gt;The answer is simple. In a Fullstack app (where you are using some framework for your front-end), you need to run two commands, one for your front-end like &lt;em&gt;npm start&lt;/em&gt; in case of React and one for your backend like &lt;em&gt;node index.js&lt;/em&gt; but platforms like Heroku can not run both of these commands simultaneously on the same host whenever you visit your app's link. Hence we deploy our backend seperately and use that link to connect it to our frontend (you can use fetch functions or &lt;a href="https://www.sitepoint.com/axios-beginner-guide/"&gt;axios&lt;/a&gt; for that).&lt;/p&gt;

&lt;p&gt;Though this was a very brief article still I hope that I cleared the most basic stuffs required to deploy your app without confusing you much.&lt;br&gt;
Wish you all the very best, Happy Coding.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to approach for help in tech ?</title>
      <dc:creator>Aadi</dc:creator>
      <pubDate>Sun, 12 Jul 2020 17:06:15 +0000</pubDate>
      <link>https://forem.com/exploreraadi/how-to-approach-for-help-in-tech-3i1h</link>
      <guid>https://forem.com/exploreraadi/how-to-approach-for-help-in-tech-3i1h</guid>
      <description>&lt;p&gt;"I didn’t hear back from him. Just because they are good at something doesn’t mean they should be arrogant, right?"&lt;br&gt;
No, they shouldn’t and maybe they aren’t. Hear me out first.&lt;/p&gt;

&lt;p&gt;We, the beginners who are just starting out on our journey in the field of Information Technology tend to be impatient and naïve initially (specially the teenagers). We get fascinated by this industry and its potential but we often don’t know from where to start or are simply lost. So, tell me what do you do when you get lost on a path? You ask for help from those who’ve walked down that road before you, right? This is where the real problem begins.&lt;/p&gt;

&lt;p&gt;We, as beginners, don’t have the slightest idea about how to approach a professional to ask queries or for suggestions and feedback. No one talks about this issue and there are barely any good articles on that but the real question is, can there be a proper guide on how to approach someone or be more social? &lt;/p&gt;

&lt;p&gt;To be honest, there can’t be. Because we humans, by nature, are social. Teaching us the same is like teaching a fish how to swim. We don’t need that but the noise of social media around, has actually made us less social and dulled our senses. We like to be empathetic behind the screens but not in reality. We don’t value time, neither ours nor others or else these things would’ve been much simpler. Just think about it. &lt;br&gt;
You are reaching out to someone for help who is really good at what they do which means two things:&lt;/p&gt;

&lt;p&gt;They’ll be humble but busy. So just introduce yourself formally, tailor your question well, be honest and respectful of their time and have some patience for the reply and woosh! You’re done. Was it hard? No. But we still don’t do it. Why? I answered that above.&lt;/p&gt;

&lt;p&gt;Sorry it was too much but if you read it till here then I won’t disappoint you now. So I'll be sharing some basic mistakes that I’ve seen beginners make and how to avoid that to increase your odds of getting a response. Here we go:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Don’t start with greetings or wait for a reply to ask your queries: &lt;br&gt;
This point needed to be at the top as I see most of the professionals being annoyed by the “Hi” and “Hello” messages or smaller chunks of messages with no clear question or subject. Please don’t do that. Do you really think they have the time for a chit chat with you? No.&lt;br&gt;
So just get to the subject of message and no, they won’t find it rude but would be happy instead that you valued their time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do your research and structure your question well:&lt;br&gt;
A half-baked message won’t get you a reply making you angry at the end and see them as arrogant (as I mentioned in the start). Trust me they are not arrogant (at least most of them aren’t). They just have a limited amount of time so make sure you have done some research and structured your message well to better your odds. This also shows that you’re serious about what you are asking and not texting them on a whim.&lt;br&gt;
A line by Eminem wraps up this point very well,&lt;br&gt;
"You only got one shot, do not miss the chance to blow"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be patient: &lt;br&gt;
As I stated before that as beginners, we are impatient but sometimes it might happen that you won’t hear back from them for days and there can be multiple reasons for that. They either missed it as they receive 100s or 1000s of such messages everyday or they marked it for later or maybe something else. Be a bit empathetic, try to understand their reasons as well and reach out again after some days or tag them in your post asking for help if you follow them. (Most of them are pretty active on twitter.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be grateful and form connections:&lt;br&gt;
Don’t be mean and have an exit as soon as you got the help you needed or else it may damage their motivation to help your peers. Thank them properly and execute their advice. Reach out to them again shortly and show your progress. Trust me, they’d be more than happy to see that and it might register your name in their head and that is the best thing you can do because these people are certainly worth sharing a good bond with.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s an example on reaching out for help with open-source:&lt;/p&gt;

&lt;p&gt;“Needed help with Open-source.&lt;br&gt;
Aditya from this side. I’ve been learning web development for few months now and have also built decent projects with react.js and finally decided to contribute to the open-source to level up my skills or land a good job but the huge codebase overwhelms me and no amount of YouTube tutorials really focuses on the extreme beginner stuffs so reaching out to you as I’ve been following you for a while and have seen you posting about your open-source contributions. Would really appreciate your guidance and suggestions.”&lt;/p&gt;

&lt;p&gt;I included the subject at the top because the first two lines of your message are what they see before even opening it (wise move, right?) and all of this in one single message. No smaller chunks, no extra cheesy stuffs, nothing.&lt;/p&gt;

&lt;p&gt;Now a personal opinion before dropping the curtains:&lt;br&gt;
Always help others with those handful of things you learned. You don’t need to be perfect or solve their problem completely but even a small help with the right intention goes a long way and who knows you might get a 100x return on that because "law of karma" exists, doesn't it?&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>community</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
