<?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 Maks on Medium]]></title>
        <description><![CDATA[Stories by Maks on Medium]]></description>
        <link>https://medium.com/@maks112v?source=rss-3de44f4bf36b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9Rhqfo5NxXepnyRMTPKFxA.jpeg</url>
            <title>Stories by Maks on Medium</title>
            <link>https://medium.com/@maks112v?source=rss-3de44f4bf36b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 22:54:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maks112v/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[From Stuck to Productive: Strategies for Moving Projects Forward]]></title>
            <link>https://maks112v.medium.com/from-stuck-to-productive-strategies-for-moving-projects-forward-8a0c176d2107?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a0c176d2107</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 16:04:13 GMT</pubDate>
            <atom:updated>2023-03-31T15:11:45.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dQr2wKEc-kGNNVQt" /></figure><p>When working on a solo project, I often experience project stalls. Sometimes, these are caused by large roadblocks with my tech stack. However, more often than not, they occur because of simpler things that make it hard to move forward. As a developer with little design experience, it is easy to come up with an idea for a feature. However, I tend to get stuck on its implementation and focus on little details, while a large part of the product is not even built yet!</p><p>I have yet to find a one-size-fits-all solution, but here are a few strategies that have consistently helped me. I’ll start with the simplest and progress to the most helpful (but harder to replicate).</p><h3>Clarifying The Issue</h3><p>I often find myself getting stuck on minor details that are not the main focus of the product. These could be small design or wording choices that are easy to change later on. The best way to get unstuck is to clarify the issue at hand.</p><p><strong>Clarification can take many forms, including:</strong></p><ul><li>A list of potential solutions with their advantages and disadvantages</li><li>A quick sketch in my notebook or on Whimsical to visualize which solution looks better</li></ul><p>Often, clarifying the issue helps make progress, but does not necessarily lead to a concrete solution.</p><h3>Breaking Up the Issue into Smaller Tasks</h3><p>When facing a large, daunting issue that is causing a project stall, it can be helpful to break it up into smaller, more manageable tasks. This makes the issue feel less overwhelming and helps you focus on specific actions you can take to move forward.</p><p>To break up an issue into smaller tasks, start by identifying the main goal or outcome you want to achieve. Then, think about the specific steps you need to take to get there. These steps should be small and concrete, with clear actions you can take to complete them.</p><p>For example, if you are stuck on implementing a new feature, you might break it up into smaller tasks like:</p><ul><li>Researching libraries or frameworks that can help with the feature</li><li>Creating a basic prototype of the feature</li><li>Testing the prototype with users or colleagues</li><li>Refining the feature based on feedback</li></ul><p>Breaking up the issue into smaller tasks can help you make progress and overcome roadblocks. It also gives you a sense of accomplishment as you complete each task, which can be motivating and help you stay focused on the larger goal.</p><h3>Getting Inspiration</h3><p>When I’m feeling stuck, one of the best things for me is seeking inspiration from other sources. This could mean:</p><ul><li>Looking at similar projects or products to see how they approached the issue</li><li>Talking to colleagues or mentors to get their input and ideas</li><li>Listening to podcasts or reading forms</li><li>Exploring new technologies or tools that could help you solve the issue differently</li></ul><p>Getting inspiration can help to approach the issue from a fresh perspective and generate new ideas for how to move forward. It can also help see the issue in a new light and identify potential solutions that were not considered before.</p><p>By using one or more of these strategies, I can usually overcome project stalls and keep making progress on my projects.</p><p><em>Originally published at </em><a href="https://maks112v.com/overcoming-project-stalls-strategies-for-developers/"><em>https://maks112v.com</em></a><em> on March 28, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a0c176d2107" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Breaking Free from YouTube’s Algorithmic Trap]]></title>
            <link>https://maks112v.medium.com/breaking-free-from-youtubes-algorithmic-trap-27b40fdc2596?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b40fdc2596</guid>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[rss]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[productivity-tips]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Mon, 16 Jan 2023 00:00:07 GMT</pubDate>
            <atom:updated>2023-01-16T17:12:12.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q_eeAfElMvK2YnzB" /></figure><h3>The Problem</h3><p>In the last few years, much has changed regarding how content is created, served, and consumed. YouTube has been a major contributor to this change, evolving from a small platform that served videos based on post date to a content powerhouse that serves thousands of hours of content per minute. <strong>Importantly, its reliance on advertising means it is not always on the consumer’s side.</strong></p><p>It is one of the best resources currently available on any topic and is used by many to learn new recipes, fix their car, or advance their career. However, the underlying truth is that the goal of YouTube is not to improve your life, but to consume as much of it as possible to increase their generated ad money. This might be a very cynical way to look at it, but that is how I feel after noticing that watching one of my favorite creators spiraled into hours of watching content that didn’t mean anything to me.</p><p>My first attempt at improving my habits around my consumption was to <strong>turn on Screen Time</strong> on my iPhone. The endeavor was helpful, but didn’t help me achieve my goal of watching more of the creators I loved in a controlled way. I didn’t necessarily want to watch less, but get lost less down rabbit holes that didn’t bring me any benefit.</p><h3>Really Simple Syndication</h3><p>I eventually found a solution that would let me watch YouTube the way I wanted by looking into <a href="https://en.wikipedia.org/wiki/RSS">RSS</a>. I was able to follow the creators I wanted to in an app that was simple and, most importantly, chronological. Once I watched a video, it would get removed from the unread list. This change has been the <strong>single biggest improvement for my content consumption</strong>.</p><p>Yes, I still do get stuck sometimes following recommendation trails, but this difference now is that it is not accidental, but an intentional use of my time I decided to do, for example, on my couch. It greatly changed my habit from seeing notifications from my favorite creators to a few lost hours of focus. Now, I can see just the creators I want to and save exploring for weekends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LH5e-MccWFCc5voU.png" /><figcaption>My Youtube RSS Setup</figcaption></figure><p><a href="https://maks112v.com/getting-started-with-rss-for-youtube/">https://maks112v.com/getting-started-with-rss-for-youtube/</a></p><p>This solution is definitely not for everyone, but I just wanted to share what has been working for me. If you’re interested in trying if this solution will work for you, I have a guide on how to get started with RSS in 5 minutes.</p><p><em>Originally published at </em><a href="https://maks112v.com/p/f580447b-60ac-4c08-bc41-e0920c1bf3e1/"><em>https://maks112v.com</em></a><em> on January 16, 2023.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b40fdc2596" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Tools From My Curated Productivity Stack for 2023]]></title>
            <link>https://maks112v.medium.com/5-tools-from-my-curated-productivity-stack-for-2023-7359436cd13e?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7359436cd13e</guid>
            <category><![CDATA[productivity-stack]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[productivity-tools]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[apps]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Thu, 12 Jan 2023 17:21:46 GMT</pubDate>
            <atom:updated>2023-01-12T17:21:46.392Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmJsRwnEBr-9WRf1TR9AbQ.jpeg" /></figure><p>As part of my ongoing side quest to improve my productivity, I evaluated many tools and tried various approaches. To help me keep track of the apps I tried and remember why I don’t use them (because I will forget and try them again…), I created a simple <a href="https://www.maks112v.com/productivity-stack/">productivity stack</a> to provide guidelines for my productivity and a reminder that productivity isn’t about the tools but about consistency. These are some of my most essential apps in my stack and why I chose them over the many other options.</p><p>If you are already comfortable with the tools you have chosen to use, try <a href="https://www.maks112v.com/notion-productivity-stack-starter/">creating a productivity stack</a> to keep track of them. If you are still looking for what works for you, read on.</p><h3>1. Notion</h3><p>Notion has come and gone from my productivity stack multiple times. I have tried alternatives like Obsidian or Craft, but every time I am without it, I feel lost. From tracking my current work to writing down plans for a trip, Notion is an important part of my day-to-day life, not just for work. It is a great place to start trying anything that might seem interesting. Want to start journaling? Make a gallery and start writing. Need to track tasks for a project? Make a list and start tracking. Instead of immediately jumping to a tool (or worse, a subscription), I explore how far I can go in Notion. This helps me learn what I really need and make informed decisions about products. Also, what ever you are thinking to do, there is probably <a href="https://www.notion.so/templates">a template for it</a>.</p><h3>2. Analog — Ugmonk</h3><p>As part of everyone’s productivity stack, I think there should be some analog element. It doesn’t matter if it’s a notebook used for journaling or a sticky note for tasks. Keeping everything digital leads to a lot of distractions, and throughout the work day, focusing on using analog always works better.</p><p>None of the other methods of integrating analog into my life stuck until I started using analog. It has the perfect blend of helping me stay focused throughout the day without having so much space, so I don’t feel like I accomplished nothing. It also helps me stay realistic about what I can accomplish in one day. Tasks that take longer than taking out the trash usually get a spot on my analog card. It’s always a great feeling to work through the day and see more and more things crossed (and when you get random distraction to deal with you can jot them on the back) off.</p><h3>3. Timemator</h3><p>So far in my career, I have had the opportunity to work remotely. There are many advantages to working at your own pace, but one downside is often overlooked: ensuring enough hours are worked in a day. It is easy to get distracted with small tasks that add up to a few hours a day.</p><p>My main defense against this is a tool called Timemator. It’s a simple time tracking app that lets me easily track my time and reminds me when I forget to stop timers and leave my computer. It has a very simple interface to review total hours and ensure that I am spending my time in the best way possible. Best of all, it is a one time payment for a very well-built native experience.</p><h3>4. Todoist</h3><p>After trying what seemed like almost every task management system possible, from Apple Reminders to Obsidian Lists, Notebooks, and corporate-style websites, the best one for me by far has been Todoist. Its simple UI makes it easy to use, and without a lot of options for how to set it up, I don’t get stuck restructuring it every few days (true story with obsidian!).</p><p>A great feature they have is to allow easy task creation with simple text, e.g. “Remind me to finish writing tomorrow at 3pm”. It also make it easy to add new tasks on desktop with the CTRL + CMD + A shortcut anywhere on macOS.</p><h3>5. Day One</h3><p>I love this app, but find it hard to use consistently. Journaling is a great way to increase enjoyment and identify any issues, but after a long day at work, it can be difficult to make the effort to write about the day. This year, I’m taking a new approach to making my journaling stick: I’m removing any expectations about length, content, or even writing at all — I may just upload a picture instead.</p><p>Those are some of the tools I use daily to stay productive. For the full list of my current productivity stack, and to learn how to make the most of them, check out <a href="https://www.maks112v.com/productivity-stack/">“What is a Productivity Stack?”</a>. Or to jump right in, create your productivity stack on this <a href="https://www.maks112v.com/notion-productivity-stack-starter/">notion template here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7359436cd13e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Productivity Stack]]></title>
            <link>https://maks112v.medium.com/productivity-stack-cc64081f3faa?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc64081f3faa</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[notion]]></category>
            <category><![CDATA[productivty-methods]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[productivity-tools]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 17:31:45 GMT</pubDate>
            <atom:updated>2023-01-09T17:31:45.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*SMZAsNhbIXC4Y-P-.png" /><figcaption>Productivity Stack</figcaption></figure><p>Productivity is an important aspect of our lives, and a productivity stack can help you stay organized and productive over a long period of time. A productivity stack is a collection of apps, services, and tools that can help you manage our tasks, prioritize our work, and stay on top of our goals. In this article, I will discuss my journey of creating a productivity stack that works for me.</p><h3>Why You Need a Productivity Stack?</h3><p>As a brief aside, the concept of a productivity stack for me arose from being a developer working with a tech stack. There are countless combinations of tech stacks that are possible, each with its own advantages and disadvantages, but ultimately the most important part is to choose one that works for you and stick with it. Just like switching tech stacks, switching productivity stacks can have a significant impact on your workflow and cause many side effects.</p><p><a href="https://www.maks112v.com/productivity-stack/">Keep Reading</a> about how to make your productivity stack or get started with a <a href="https://www.maks112v.com/notion-productivity-stack-starter/">free notion template</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irsUtdk9QdlVGreRHKanmw@2x.png" /><figcaption>Productivity Stack Template</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc64081f3faa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to structure a… NextJs Project]]></title>
            <link>https://maks112v.medium.com/how-to-structure-a-nextjs-project-a1d42b5cb141?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1d42b5cb141</guid>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[structure]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Sat, 24 Apr 2021 20:40:30 GMT</pubDate>
            <atom:updated>2021-04-24T20:41:56.065Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>TLDR</strong>: If you just want to start <a href="https://github.com/maks112v/nextjs-structure/blob/master/README.md">clone the template</a> and read the README.md files in each folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhqceS0Dq_z1khwzgB66Zw.png" /></figure><h3>What is this?</h3><p>How to structure a… is going to be a new series of posts where we will explain how we structure curtain frameworks and the process that we went through to get to these setups. We are constantly trying to improve on this process, so there will probably be regular changes to how structure our project and it will also slightly very per app. On a typical app we will not have all these folders but just the ones required. All of these are just recommendations we settled on after a few projects and revisions which should be adapted to your use-case and team preferences.</p><blockquote><em>“The only constant in life is change”<br></em>- Heraclitus</blockquote><h3>Why Have a Constant Folder Structure</h3><p>An awesome and consequently difficult part of React and Nextjs is the lack of structure in development. This is quickly noticeable for anyone working on with a team or switching from a different more opinionated framework. It can lead to many problems or slow downs in development but here are a few issues we ran into:</p><ul><li>Duplicate components and styles</li><li>Broken imports</li><li>Difficult to work in and onboard new team members</li><li>Unoptimized code</li><li>Lost code (someone deleting coding or branch that is in use)</li></ul><h3>The Concepts</h3><p>A few fundamentals to ponder.</p><h3>Consistency is Key.</h3><p>No matter how good the folder structure or plan is it won’t do any good unless everyones sticks to it. This might mean modifying the structure to the current project or the teams preferences to make it more enjoyable to work with. Consistency don’t only include folder structure but also function / file naming, imports and exports, interfaces and what technologies should be used. It would be helpful to write these down in a technical outline (see the example for more details). We try to use Typescript when possible to improve consistency in our projects and encourage best practices.</p><h3>Naming &amp; Case</h3><p>The start of any consistent structure is naming and casing of files and functions. When used correctly they can give a lot of context around a function and the purpose. For example if we were looking at a file in NextJs called components/UserProfile.tsx this would let us know that it is reusable React component which we can import and use. It also gives us an efficent way to search for it by typing something like: comp user pro this is really powerful in a large app with many components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*HUGGutDjFZ21r-BKZn29OA.png" /></figure><p>We typically try to use semantic names to the function of the component a few examples would be:</p><ul><li><strong>TextInput.tsx / SelectInput.tsx / CheckboxInput.tsx</strong></li><li>Inputs that styled and based on the project might be handled by formik</li><li><strong>ProfilePage.tsx / HomePage.tsx</strong></li><li>Pages that are inside of the pages folder in nextjs and should not be imported</li><li><strong>LoginOverlay.tsx / ErrorOverlay.tsx</strong></li><li>Full screen overlays that are used to be rendered instead of a page</li></ul><p>There are many ways to name files and functions semantically and this is just the idea we are currently using which each project having a bit of its own spin on the idea based on the requirements.</p><h3>The Structure</h3><p>Finally something applicable</p><p>As every framework or even project has different requirements, this section is going to be based on NextJs with multiple app combined to give you the best options to pick from. If any of these folders are not used that is okay as long as you follow concept number one… <strong>Consistency.</strong></p><h3>Folders</h3><p>As this is a general list of semantic folder names it will also contain a description of it’s use and the recommended file naming.</p><h3>components</h3><p>Naming: PascalCase.tsx</p><p>Pieces of code that are reuse-able independently and made dynamic with props typically, do not share state. If there are many components with the same ending name like Input we will put them in a sub folder and possibly use and index.ts to export it cleanly</p><p>Examples:</p><ul><li>Card.tsx</li><li>Seo.tsx</li><li>Button.tsx</li><li>TextInput.tsx</li></ul><h3>data</h3><p>Naming: camelCase.ts</p><p>Stores data that is static or changes rarely. Could be options for forms such as states or application specific content such as for a marketing site.</p><h3>hooks</h3><p>Naming: camelCase.ts</p><p>Anything that has the word use in front of it but <strong>doesn&#39;t contain use context.</strong></p><p>Examples:</p><ul><li>useStickyState.ts</li><li>useCountdown.ts</li><li>useDebounce.ts</li><li>useInput.ts</li></ul><h3>libs</h3><p>Naming: camelCase.ts</p><p>Libs stands for application specific libraries. These could be used to interact with an api or with the window element.</p><p>Examples:</p><ul><li>sendMessage.ts</li></ul><h3>services</h3><p>Naming: camelCase.tsx/ts files with 1 capital export for wrapper</p><p>Anything that references a wrapping context or outside service or api including firebase, mongodb, react context. Should typically be a wrapping component or an import. If it is a wrapping component it should have one capital export and have a file name ending in .tsx else have the name end in .ts</p><h3>ts</h3><p>Naming: camelCase.ts</p><p>Typescript definitions exports. We prefer to keep the exported interfaces fully capital with _ to make them easy to find in code.</p><h3>utils</h3><p>Naming: camelCase.ts</p><p>An abbreviation of utilities. Should contain very short and specific functions used throughout components and in <strong>libs.</strong></p><p>Examples:</p><ul><li>formatNumber.ts</li></ul><h3>Imports</h3><p>To keep our code readable and make it easy to rearrange components when needed we use typescript absolute imports. To set it up all that is needed is to add snippet at the end of compilerOptions in the tsconfig.json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BY_yRlxrAGElF-yNCRmspg.png" /></figure><pre>&quot;baseUrl&quot;: &quot;.&quot;,<br>  &quot;paths&quot;: {<br>    //? Folders<br>    &quot;@components/*&quot;: [&quot;components/*&quot;],<br>    &quot;@data/*&quot;: [&quot;data/*&quot;],<br>    &quot;@hooks/*&quot;: [&quot;hooks/*&quot;],<br>    &quot;@libs/*&quot;: [&quot;libs/*&quot;],<br>    &quot;@services/*&quot;: [&quot;services/*&quot;],<br>    &quot;@ts/*&quot;: [&quot;ts/*&quot;],<br>    &quot;@utils/*&quot;: [&quot;utils/*&quot;],<br>    //? Files<br>    &quot;#project&quot;: [&quot;project.config.ts&quot;]<br>  }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1d42b5cb141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get started with TypeScript in ReactJs]]></title>
            <link>https://maks112v.medium.com/how-to-get-started-with-typescript-in-reactjs-aed7ffb0e7d4?source=rss-3de44f4bf36b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aed7ffb0e7d4</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Maks]]></dc:creator>
            <pubDate>Sat, 17 Apr 2021 19:02:45 GMT</pubDate>
            <atom:updated>2021-04-19T01:53:39.347Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to get started with TypeScript in NextJS</h3><p><strong>TLDR</strong>: <em>Useful tips to improve or start using typescript that scale to large projects.</em></p><p>This guide is to help you extend or easily get started with typescript in a NextJs project. These are tips and workflows I learned over the course of using typescript both professionally and for personal project that helped me improve my code and simplify the debugging process.</p><figure><img alt="https://cdn-images-1.medium.com/max/1600/1*f5rhsoC-RDYUE417FsgIMg.png" src="https://cdn-images-1.medium.com/proxy/1*f5rhsoC-RDYUE417FsgIMg.png" /><figcaption>Typescript Button Component</figcaption></figure><h3>The Boring Stuff</h3><p><strong>Learn why I use Typescript the way I do.</strong></p><p>If you want to see the tips on typescript keep scrolling. I started using typescript to improve my code and help me manage errors. At first I wasn’t able to find a lot of use cases not knowing how to use typescript effectively in react. Overtime as I learned new use cases and saw others developers code I learned a few tricks that helped me understand the role typescript plays in development and how to use it effectively in team or personal projects.</p><h3>Getting started</h3><p><strong>Just adding typescript,</strong> there are much better guides than this.</p><p>To start using typescript in an nextjs project just create a tsconfig.json file. To learn more about getting started look at the <a href="https://nextjs.org/docs/basic-features/typescript">Nextjs Guide to adding Typescript</a></p><pre>touch tsconfig.json</pre><p>and <strong>restart your development server</strong>!</p><pre>yarn dev</pre><p>It will prompt you to install a few packages</p><pre>yarn add typescript @types/react --dev</pre><p>Again restart the dev server and there will be some config added to the tsconfig.json file in your project root</p><h3>🎉 Congratulations you now have a project with typescript</h3><p>Lets rename all the files in pages to use TypeScript. This script will find all the files in pages and rename them to .tsx which is a Typescript React File</p><pre>find pages -name &quot;*.js&quot; -exec sh -c &#39;mv &quot;$0&quot; &quot;${0%.js}.tsx&quot;&#39; {} \;</pre><h3>The Basics</h3><p>Creating a typescript component</p><p>The goal of typescript is to make coding easier by simplifying the process of reading, understanding, and debugging code. After install typescript you can use NextJS the but lets create a button component with typescript</p><h3>A Button Component</h3><p>Inside of the a components folder create a Button.tsx and lets start by adding my favorite typescript snippet to a component. I created this snippet to make it easy to use and export the Button prop type.</p><pre>import React, { FunctionComponent } from &#39;react&#39;;</pre><pre>interface ButtonProps {}</pre><pre>const Button: FunctionComponent&lt;ButtonProps&gt; = ({ children }) =&gt; {<br>  return &lt;button&gt;&lt;/button&gt;;<br>};</pre><pre>export default Button;</pre><p>Next let’s add a text props and add its type into the interface. This will help us when passing down props and seeing what is allowed. Also in text editors like VS Code you will get a list of possible props you can pass down to the component.</p><pre>import React, { FunctionComponent } from &#39;react&#39;;</pre><pre>interface ButtonProps {<br>  text?: string;<br>}</pre><pre>const Button: FunctionComponent&lt;ButtonProps&gt; = ({ text }) =&gt; {<br>  return &lt;button&gt;{text}&lt;/button&gt;;<br>};</pre><pre>export default Button;</pre><p>Using Typescript in this kind of pattern can help us to prevent errors from incorrect props and require props by removing the ? in the interface. These errors will be caught at run time or can be caught with a linter (post coming soon)</p><h3>Extending an Interface</h3><p>This is something that took me a while to learn but is very helpful at making manageable interfaces. Let’s add support for passing any other prop to button. It might seem easy to add [key: string]: any to the interface to make it easy but instead we should extend our interface with the correct button interface from React to get full types.</p><p>The find the correct type to use we can hover over the element we want to extend in vscode and it will show the type after the:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Vf0NakhhOoHnj7Fs-m3_A.png" /><figcaption>Hovering over an element in VSCode</figcaption></figure><p>In this case the type is</p><p>React.DetailedHTMLProps&lt;React.ButtonHTMLAttributes&lt;HTMLButtonElement&gt;, HTMLButtonElement&gt;</p><p>We can use that to extend our button interface and pass the rest of our props to the button</p><pre>import React, { FunctionComponent } from &#39;react&#39;;</pre><pre>interface ButtonProps extends React.DetailedHTMLProps&lt;React.ButtonHTMLAttributes&lt;HTMLButtonElement&gt;, HTMLButtonElement&gt; {<br>  text?: string;<br>}</pre><pre>const Button: FunctionComponent&lt;ButtonProps&gt; = ({ text ,...rest }) =&gt; {<br>  return &lt;button {...rest}&gt;{text}&lt;/button&gt;;<br>};</pre><pre>export default Button;</pre><p>We should now see the rest of the prop options we have from that component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wiyb0dsmbpSKGsC8Oa8hqw.png" /><figcaption>Props from extended interface</figcaption></figure><p>Extending existing interfaces or types can keep our code a lot cleaner and make it easy to remember what we can pass to a specific component or function.</p><p>We can see that we also assign the type of FunctionComponent to the button above to allow destructing children and other props that are part of react element</p><h3>Absolute Imports</h3><p>A very important part of keeping a project clean is the folder structure and imports. Typescript in NextJs can help by changing our imports from this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzGMk9SakICAtxiTnfo97Q.png" /><figcaption>Relative imports</figcaption></figure><p>To this very easily</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OeXHU6mahCBUwJWSC7lK0g.png" /><figcaption>Absolute imports</figcaption></figure><p>To get started just add this inside the complierOptions in the tsconfig.json</p><pre>&quot;baseUrl&quot;: &quot;.&quot;,<br>  &quot;paths&quot;: {<br>    //? Folders<br>    &quot;@components/*&quot;: [&quot;components/*&quot;],<br>    &quot;@data/*&quot;: [&quot;data/*&quot;],<br>    &quot;@graphql/*&quot;: [&quot;graphql/*&quot;],<br>    &quot;@lib/*&quot;: [&quot;lib/*&quot;],<br>    &quot;@services/*&quot;: [&quot;services/*&quot;],<br>    &quot;@ts/*&quot;: [&quot;ts/*&quot;],<br>    &quot;@utils/*&quot;: [&quot;utils/*&quot;],<br>  }</pre><p>The final file should look something like this</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es5&quot;,<br>    &quot;lib&quot;: [&quot;dom&quot;, &quot;dom.iterable&quot;, &quot;esnext&quot;],<br>    &quot;allowJs&quot;: true,<br>    &quot;skipLibCheck&quot;: true,<br>    &quot;strict&quot;: false,<br>    &quot;forceConsistentCasingInFileNames&quot;: true,<br>    &quot;noEmit&quot;: true,<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;module&quot;: &quot;esnext&quot;,<br>    &quot;moduleResolution&quot;: &quot;node&quot;,<br>    &quot;resolveJsonModule&quot;: true,<br>    &quot;isolatedModules&quot;: true,<br>    &quot;jsx&quot;: &quot;preserve&quot;,<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      //? Folders<br>      &quot;@components/*&quot;: [&quot;components/*&quot;],<br>      &quot;@data/*&quot;: [&quot;data/*&quot;],<br>      &quot;@graphql/*&quot;: [&quot;graphql/*&quot;],<br>      &quot;@lib/*&quot;: [&quot;lib/*&quot;],<br>      &quot;@services/*&quot;: [&quot;services/*&quot;],<br>      &quot;@ts/*&quot;: [&quot;ts/*&quot;],<br>    }<br>  },<br>  &quot;include&quot;: [&quot;next-env.d.ts&quot;, &quot;**/*.ts&quot;, &quot;**/*.tsx&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;]<br>}</pre><p>Now just restart the development server and change any imports to use @components/</p><h3>Conclusion</h3><p>Typescript is a very to any team or project and can improve development when used properly. Soon I will also show how to improve the functionality but adding linting to prevent bad code from being committed to github.</p><blockquote><em>This is my first attempt at teaching myself by teaching others. If you have any feedback please let me know.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aed7ffb0e7d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>