<?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 Vincas Stonys on Medium]]></title>
        <description><![CDATA[Stories by Vincas Stonys on Medium]]></description>
        <link>https://medium.com/@vincasstonys?source=rss-c8cc74215403------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jSuDAPOqBVHldrzqOjTHbQ.jpeg</url>
            <title>Stories by Vincas Stonys on Medium</title>
            <link>https://medium.com/@vincasstonys?source=rss-c8cc74215403------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:08:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vincasstonys/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[What Chess Teaches About Business and Life]]></title>
            <link>https://vincasstonys.medium.com/what-chess-teaches-about-business-and-life-3e63a71688eb?source=rss-c8cc74215403------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e63a71688eb</guid>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[lessons-learned]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[chess]]></category>
            <dc:creator><![CDATA[Vincas Stonys]]></dc:creator>
            <pubDate>Tue, 14 Mar 2023 16:19:16 GMT</pubDate>
            <atom:updated>2023-03-14T16:19:16.221Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here are 10 lessons chess taught me.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_VUDsnlfurIWn19Q.png" /><figcaption>Cats playing chess, generated with DALL-E 2.</figcaption></figure><p>Over my life, I’ve played more than 1,000 hours of chess.</p><p>I’m not a great player, but clearly — I love the game. If I allowed myself to, I could obsess over it for weeks on end. I like how it mixes abstract strategy, deep calculation, and even a psychological component.</p><p>Over the last couple of years, I’d been listening to what some smart people say about business and life, and I was surprised by how many lessons I’d already learned… <em>in chess</em>.</p><h3>Lesson One</h3><blockquote>Knowing the basic principles will make you better than 95% of all people.</blockquote><p>Most people know the rules of chess. But knowing the rules does not mean you can play. If you spent just 10–20 hours learning and practicing the basic principles of strategy and tactics, you’d beat them most of the time.</p><p>I’ve found that this thinking applies in many areas of life and business as well. I remember watching an episode of <em>Ramsay’s Kitchen Nightmares</em> — the lady owning the restaurant had never learned how the kitchen works and it was the reason her restaurant was failing. After Ramsay put her to work in the kitchen for a few nights she quickly started seeing all sorts of issues and <a href="https://www.realitytvrevisited.com/2011/05/us-season-3-episode-5-lido-di-manhattan.html">turned her restaurant around</a>.</p><p>In a time where everything must be condensed to a 300-character Tweet, or a 15-second TikTok, being able to spend a few days learning a subject is quickly becoming a superpower.</p><h3>Lesson Two</h3><blockquote>A poor plan is better than no plan at all.</blockquote><p>Why do people who know something about chess strategy win against those that don’t?</p><p>Because they’re able to formulate a plan. Sure, if you’ve only watched a couple of tutorials on YouTube, your plans won’t be good — but you have a baseline that you can improve on.</p><p>When you have no plan, all you can do is wander aimlessly and hope that some random luck will strike you. You don’t need to look hard to see that this is true about life as well — is there anyone around you who just seems to let life throw them around? Yeah.</p><h3>Lesson Three</h3><blockquote>Most of the game is uneventful.</blockquote><p>As a beginner, I used to always attack. I used to constantly look for tactics, certain that this was the only way to win the game. I only started to get better after I read some books on positional play.</p><p>Turns out, fireworks and winning combinations are rare in good players’ games. A lot of the game is just improving the placement of your pieces slowly and methodically.</p><p>If you’re looking for action on every corner, you’re looking for trouble. Which leads to…</p><h3>Lesson Four</h3><blockquote>Tiny improvements compound over time.</blockquote><p>If you’re always improving your position, and your opponent does not, your advantage will compound to the point that a winning combination will naturally present itself. You won’t even have to look for it.</p><p>Your job is then to simply cash out by executing some tactic.</p><p>The topic of compounding is a big one in business and life, and I love how <a href="https://twitter.com/AlexHormozi">Alex Hormozi</a> puts it:</p><blockquote><em>Extraordinary results are achieved by people who do ordinary things for extraordinary periods of time.</em></blockquote><h3>Lesson Five</h3><blockquote>Good players aren’t good because they always find good moves.</blockquote><p>They’re good because they’re not making bad ones.</p><p>When two good players play, opportunities for crushing moves are rare — you’re lucky if you get a chance to make one at all. So if you want to be good, don’t obsess about finding the best moves — focus on never making a bad one.</p><p>Warren Buffet famously said:</p><blockquote><em>Rule No 1: never lose money.</em></blockquote><blockquote><em>Rule No 2: never forget rule No 1.</em></blockquote><p>This leads me to believe that the principle is as much true in business as it is in chess.</p><p>You might get one or two life-changing opportunities. Until then, improve your position, but when you do get a chance to go big — make it count.</p><h3>Lesson Six</h3><blockquote>Admitting a mistake is better than blindly defending it.</blockquote><p>Sometimes you just miss <em>that</em> move. We make mistakes, and that’s fine. What’s important is what comes after it.</p><p>It’s no use trying to twist reality in a way that your mistake is not a mistake anymore. Simply admit it, backtrack, and make a different move.</p><p>It took me a while to learn this one. Somehow I was adamant about never moving my pieces back — I had to prove I <em>wasn’t</em> wrong in the first place (even though I was).</p><p>The only piece that can’t be moved back is a pawn — just like some decisions in life are irreversible. Leading to…</p><h3>Lesson Seven</h3><blockquote>Think before making a move.</blockquote><p>Sounds obvious, right? Well, it wasn’t for me, and I bet you fell into this trap at some point as well.</p><p>After I got a little better at chess, I started making some moves on autopilot — not based on some sound line of reasoning.</p><p>Even if I spent a good chunk of time thinking, I would often end up making a move based on a gut reaction — a move I wasn’t even considering initially. Then I would try to rationalize the move post-factum, trying to come up with reasons why that move is, in fact, good.</p><p>Only after I started forcing myself to think before making my moves, I noticed my results improve.</p><h3>Lesson Eight</h3><blockquote>There’s opportunity in chaos.</blockquote><p>Sometimes when you’re losing, your best bet is to make a move that complicates the position as much as possible. This increases the odds of your opponent making a mistake or some unexpected tactics coming up.</p><p>The most stressful games for me were the ones where I was clearly winning, but the opponent made a dubious sacrifice and now I had to prove myself. Don’t underestimate this psychological aspect.</p><p><a href="http://www.chesspersonality.com/type/magician">Mikhail Tal</a> was a chess world champion, and he had a saying:</p><blockquote><em>There are two types of sacrifices: correct ones, and mine.</em></blockquote><p>He was so good at creating complicated positions at unexpected moments and taking advantage of opportunities they created that he got a nickname — <em>The Magician of Riga</em>.</p><p>Sometimes in life, it’s good to shake things up a bit. In my case — to leave a job and explore what’s out there.</p><h3>Lesson Nine</h3><blockquote>Don’t spend resources for no reason.</blockquote><p>In chess, pieces are resources. And beginner chess players are all too happy to exchange their pieces. However, this is not how good players play.</p><p>The more pieces you have on the board, the more flexibility you have, and the more opportunities you can take advantage of. That’s why in chess, you should strive for every trade to be in your favor.</p><p>It’s the same in business and life — if you’re stuck at your 9–5 you won’t be able to jump on good opportunities as they come up. In fact, you probably won’t even notice them.</p><p>When you choose to tie up your resources like that, you’d better make sure you’re going in the direction you <em>really</em> want.</p><h3>Lesson Ten</h3><blockquote>Good moves are often simple.</blockquote><p>I’ve lost countless games by miscalculation complex “winning” tactics.</p><p>It’s usually better to make a few clear moves that net you a small advantage than to calculate a 10-move tactic that <em>maybe</em> wins immediately. The deeper you go, the more likely you are to miscalculate.</p><p>In life, this principle has been known for hundreds of years in the form of <em>Occam’s razor</em>, which basically says:</p><blockquote><em>When faced with two possible explanations, the simpler of the two is the most likely to be true.</em></blockquote><p>In general, what can be made simple shouldn’t be made complex.</p><p>Turns out, chess can teach a lot about business and life…</p><p><strong>Was there anything you did that unexpectedly taught you something about business or life? </strong>I’d love to hear the story! For me, another big one was video games, but that’s for another time.</p><p>If you’ve enjoyed it so far, I share my thoughts, experiences, links &amp; inspirations (just like this one) in my newsletter — feel free to subscribe 👇</p><p><a href="https://vincasperspective.substack.com/?r=1sxu31&amp;utm_campaign=pub-share-checklist">The Vincas Perspective | Vincas Stonys | Substack</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e63a71688eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning to Run an Online Tea Shop]]></title>
            <link>https://vincasstonys.medium.com/learning-to-run-an-online-tea-shop-2b230dbb1c8d?source=rss-c8cc74215403------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b230dbb1c8d</guid>
            <category><![CDATA[tea-shop]]></category>
            <category><![CDATA[startup-lessons]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[progress-update]]></category>
            <category><![CDATA[e-commerce-business]]></category>
            <dc:creator><![CDATA[Vincas Stonys]]></dc:creator>
            <pubDate>Wed, 09 Mar 2022 08:12:24 GMT</pubDate>
            <atom:updated>2022-03-09T08:12:24.458Z</atom:updated>
            <content:encoded><![CDATA[<p>I work the typical 9–5 as a Software Engineer while also running an <a href="https://vistontea.com/">online tea shop</a> — I will show you how I’m doing it. Six months ago I started <a href="https://vistontea.com/">Viston Tea</a> and wrote an <a href="https://vincasstonys.medium.com/why-i-sell-tea-as-a-software-engineer-b904504e6527">article</a> about the reasons why I’m doing it, and this is the update of my first six months running Viston Tea.</p><p>Previously I talked about how I wanted to start building something of my own, that would help escape the unfulfilling grind that is working every day for somebody else, building things that are, at best, only remotely interesting.</p><p><a href="https://medium.com/@_michaellin/why-i-quit-a-450k-engineering-job-at-netflix-874454397885">More</a> and <a href="https://dvassallo.medium.com/only-intrinsic-motivation-lasts-92c0497cf97c">more</a> people are becoming disillusioned with the 9–5, even the “successful” ones, and I wholeheartedly relate with what they’re talking about — I too want to embrace the discomfort of finding my path, that’s why I started selling tea.</p><p>I hope that by sharing my journey I can inspire more people to pursue their interests and do something exciting.</p><h3>Finding a mentor</h3><p>The first thing I realized — is that I know nothing about running a business, so I wanted to find some help. I used <a href="http://mentorcruise.com/referrals/4mVCbu8FUzI1pFRUscjAYsZNstfREjfa5GhOO9UA/">MentorCruise</a> to find a mentor to guide me and help me set priorities for the limited time that I have.</p><p>This was the best decision ever! I honestly recommend everyone get a mentor when beginning with a new skill. Reading articles, books, and watching course videos can only get you so far — at some point, you will have questions or need some professional feedback — this is where mentors shine.</p><p>We meet every 1–2 months and talk about any issues I’m facing and learn about some aspects of building a business — marketing, building a product, building a sales funnel, email campaigns, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COeHZN34bpgDu0XTjqzsxg.png" /><figcaption>A snapshot of meeting notes with my mentor.</figcaption></figure><p>The first order of business was to start building traffic, with my limited budget we decided to go with content marketing.</p><h3>Starting a blog</h3><p>One of the most reliable ways to build traffic over time is by creating content regularly. That’s the fundamental principle if you want to grow on Youtube, Instagram, or Google.</p><p>There’s a lot to say about tea, and blogging has a comparatively low barrier of entry, so I decided to start a <a href="https://blog.vistontea.com/">tea blog</a>. After some deliberation, I decided to use WordPress and host it on a subdomain of vistontea.com at <a href="https://blog.vistontea.com/">blog.vistontea.com</a>. I wrote my first article on making tea and asked for some feedback on Reddit.</p><p>Turns out, there’s a whole <a href="https://www.growthmachine.com/blog/seo-case-study">case study</a> written about growing a tea blog (and any other blog for that matter)!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*44xgHpXxETaY6zhGzHkX6g.png" /><figcaption>I immensely enjoyed learning from Nat Eliason — he’s not only a great content marketer but also an interesting personality.</figcaption></figure><p>If you’re considering starting a blog I very highly recommend looking up Nat Eliason’s guide.</p><p>Writing a blog is a long-term play, here are the basic steps I’d need to follow:</p><ul><li>Write at least 1–2 blog posts a week (I fail at this miserably).</li><li>Optimize for search engines — very important for content marketing blogs, not necessarily as important for personal blogs (but useful nonetheless).</li><li>Promote — build links to my blog through guest posting, commenting on other blogs, social media, etc.</li></ul><h4>Writing a blog</h4><p>Turns out writing isn’t easy.</p><p>I have an innate drive to seek out the most objective information possible, which means I need to go over credible scientific research when writing an in-depth article, which takes a lot of time and effort.</p><p>I had a goal to write 1–2 articles per week, but so far I’m doing 1–2 per month at best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbq6ySJUZaBdBiDpydkMgg.jpeg" /><figcaption>My blog post progress tracker since January 1st. I’m not even close to making good progress…</figcaption></figure><p>Optimizing a blog wasn’t a big deal since I’m a web developer professionally. Most of the concepts are already familiar and there’s tons of material online about optimizing WordPress blogs. Nat’s guide covers this aspect as well.</p><h4>Promoting a blog</h4><p>If you search for guides to promote your blog, what you’re sure to find is Pinterest guides. Everyone seems to <em>love</em> <a href="https://www.pinterest.com/vistontea/">Pinterest</a>, so I decided to try my hand at it.</p><p>I got myself Tailwind, as it’s the most recommended tool out there, for scheduling Pinterest posts. I diligently followed recommendations for pinning and repinning, but I’m yet to see any substantial results. I tend to barely get a hundred daily views, out of which I get probably 1–3 outbound clicks a month.</p><p>So far Pinterest has been a waste of time and effort for me — I could get the one outbound click by personally asking one person to visit my blog and I’d save hours of time. It seems like Pinterest is best for “tea party ideas”, recipes, fashion, organization, DIY ideas, and such.</p><p><em>As a side note — I initially didn’t want to pay for Tailwind, so I spent 2–3 weeks building a tool that can schedule pins and repins. However, Pinterest limits the necessary access to its Partners, which gives tools like Tailwind an extreme advantage. I do NOT recommend Tailwind to anyone — it’s an atrocious mess of idiotic design and user-experience decisions and a slow and clunky interface. It only lives because of its partnership with Pinterest and affiliate program, otherwise, even a high-school student would make something better.</em></p><h3>Getting featured</h3><p>I almost accidentally got featured on <a href="https://www.worldteanews.com/profiles/being-young-tea-entrepreneur-software-engineer-lithuania">World Tea News</a>. In an attempt to promote my blog I contacted various tea newsletters asking them to share my blog posts in their newsletters. They never agreed to it.</p><p>However, an editor of World Tea News got interested in my story and asked me to give an interview about my new tea business! Sometimes things don’t go the way you’d hoped, but still, turn out great…</p><p>I don’t think the featured article did anything for my tea shop, however, I did make a few useful contacts and I can now add their logo to my website’s “featured on” section for social proof.</p><h3>First non-family-and-friends customers</h3><p>In August, 1 day after I posted my first article I got my first customer who wasn’t a family member. It was somebody from the USA. They ordered a bundle of black teas. I tried contacting them, however, they never responded.</p><p>In November, I decided to launch a Black Friday/Cyber Monday deal. I made a banner for it and promoted it on Reddit. Throughout the 2 weeks, I got one sale. It was from a person named Jesse. He contacted me personally via email and we chatted for a while. He was even kind enough to <a href="https://blog.vistontea.com/community-tea-preparation-tips/">share his knowledge about tea preparation</a>!</p><p>He became a fan of my tea shop and a recurring customer ever since.</p><h3>Launching new teas</h3><p>Three kinds of black tea would not be enough for a successful tea shop. So in Autumn, I focused on releasing a few new teas and redesigning my Shopify store.</p><p>I decided to add 3 green teas and 3 specialty teas (puerh, oolong, genmaicha) to my tea shop. Here’s what they look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMTr143mWTWLEtfPENQoog.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MSmOblH2ZxkeCbSB2SRAg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5uXY-oszphPfjXlFTJNp7A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CuqoHtfDqYZV0OVCxLKDg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pav_KabuTCxSubxBEQqM8A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1AZODLfSB_ZUGzvlE_qDg.jpeg" /></figure><p>At the same time, I refreshed the product photos in my store. I think they look fine now, but definitely not professional yet. I took them in bad lighting and used a makeshift rig. I probably should’ve taken the photos as a composition — a flat lay or in a cozy environment — that would distract from the imperfections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kVcmYg2a1NOvFwZGK813vQ.jpeg" /><figcaption>Me taking photos using a makeshift rig. It’s obvious I’m not a photographer…</figcaption></figure><p><em>As a side-project, I looked into creating apps for Shopify. I needed an app to show WordPress blog posts on my Shopify storefront. However, they tend to cost at least 5$ per month, which is ridiculous, as it’s pretty much 3 lines of code. I will probably explore creating Shopify apps at some point in the future. If you’re looking for some coding side-projects, that are perfect for beginners even, try building some Shopify apps.</em></p><h3>Taking it to the next level</h3><p>As the new year came I decided to take the tea shop to the next level. However, there’s still the main issue of not getting enough traffic, let alone converting it. I keep trying to tweak the messaging in my shop and about pages, but it’s hard to verify anything without being able to test with a large enough audience.</p><h4>Setting up a funnel</h4><p>My mentor recommended being more intentional with my writing and shop design. I needed to set up a funnel — capture interested visitors’ contacts and lead them through a series of steps to convert them into a customer. I had already set up <em>some </em>email automation, but it was scattered across many different tools — Sendinblue, Shopify, several opt-in apps, etc. I decided to move everything, to Klaviyo — both for the shop and the blog.</p><p>Me and my mentor came up with email campaigns to create a basic funnel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ynFHw-3iITFLFh3PjjpBg.png" /><figcaption>The flowchart of a funnel we came up with.</figcaption></figure><p>I’ve implemented parts of it — abandoned cart, part of the welcome flow, review requests, and others, but I’m yet to completely implement it.</p><p>Working with Klaviyo is not very straightforward, but as a developer I had no issues getting the hang of it. I strongly recommend it — it’s very powerful and has very reasonable plans. The only gripe I have is that the email editor gets very slow after a while.</p><h4>Writing more content</h4><p>I’m a slow writer (took me 6 months to write a follow-up article on medium). I needed a way to make the output more regular and more frequent. The idea I had is to <a href="https://blog.vistontea.com/jager-tee-wiener-opern-melange-review/">write tea reviews</a>.</p><p>The idea with reviews is that:</p><ul><li>They’re quite quick to write</li><li>They’re more personal, as opposed to SEO content — people may keep returning to the blog for the reviews</li><li>They’re a form of SEO, where people looking for a different tea brand or product may come across my blog and tea shop</li></ul><p>I calculated that I can meet my goals of 1–2 articles per week if I wrote ~300 words per day. I would like to build that kind of habit, I think it would be invaluable.</p><p>For the time being though, I’m looking for some outside help with writing content. I experimented a bit with <a href="https://www.verblio.com/">Verblio</a> following a recommendation from a person I follow on Twitter, however, the writing quality was extremely poor. I’m now looking for writers in local Facebook groups, and that seems a lot more promising so far.</p><h4>Starting a company</h4><p>I knew that at some point I would have to start a company for my tea business. Up until now, I’ve been operating under my <em>“individual economic activity certificate”</em>, which I used for freelance and contract work.</p><p>I kinda regret not starting the company sooner though. I thought I would save some paperwork, but in the end, I wasted time, effort, and money. I’ve been managing my accounting for the last 6 months myself — I had to file for VAT and declare taxes, which always took 1–2 days every month to figure out.</p><p>As a business I get these perks:</p><ul><li>I don’t have to file for VAT with my current income from tea, so accounting is 10x easier;</li><li>I can file expenses, so I only need to pay profit (corporate) tax instead of income tax;</li><li>In Lithuania — for the first year the business will pay 0% tax, and for subsequent years, likely only 5%. I’m not planning on taking out any cash from the business, so I don’t need to worry about personal income taxes.</li><li>I’m protected from civil responsibility (corporate shield).</li><li>I get to use incentives offered to new businesses, like vouchers for free google ads, free ads in local newspapers, discounts for shipping and more.</li><li>I could employ people if I wished to.</li></ul><p>I kinda wish I’d started the company sooner.</p><h4>Future plans</h4><p>I’m starting to feel like my tea business is starting to pick up the pace after 6 months — I’m starting to get more ideas, more traffic and more customers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*qAE9ukJU8lgoSO7x0sBRvg.png" /><figcaption>My sales for the last 6 months.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAn7SNlCVTVUptLqddPsng.png" /><figcaption>Shopify store traffic for the last 6 months.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f496eeLswcl3s9LfmYbRoQ.png" /><figcaption>Google search stats for the last 6 months.</figcaption></figure><p>My main ideas for the near future (i.e. next 6 months or so) are:</p><ol><li>Start direct sales — I’m a Software Engineer, so I’m familiar with working in the office. I think it would be rather easy to convince office managers to get some tea for their office. In addition to making a sale, it would also introduce it to a large number of people. It’s probably something I should’ve started within the beginning.</li><li>Get professional photos — I took all of the photos myself. They kinda suck. I’ve already found a photographer, so in the near future, I will have high-quality photos I can use for my products and social media. This was my first investment as a business.</li><li>Refresh the product and shipping prices — having set up the company, I now have more flexibility in my product pricing. I could reduce the shipping cost and introduce a few more methods of shipping too.</li><li>Collaborate with influencers — I have ideas for collaborations with influencers. There are some youtube vloggers who like tea, I think I would contact them first. I need to start to promote my tea brand more effectively.</li><li>New packaging — current packaging is alright, and I’ve had some praise for my label designs. However, I don’t think the packaging is Instagram-worthy. I have some ideas for a new packaging already.</li><li>Outsource as much as I reasonably can — I’ve outsourced photography, I’m working on outsourcing writing. In the future, I will outsource packaging teas as well and hopefully more. I talked to a colleague of mine who’s started a successful tutoring business and what he recommended me to do is — outsource to students! I think that’s an excellent idea — students are affordable, motivated, and usually have access to professional facilities.</li></ol><p>I already spent more than my budget of 1000 euros I set half a year ago. However, since then I started looking at this project as a long-term project.</p><p>I started “Viston MB” company with 2500 euros in a bank account, which should be enough for the initial investments in photos, outsourcing writing, influencer collab, packaging, and tea. However, I’ve been learning so much, that the knowledge I’ve gained is already invaluable.</p><h3>Final thoughts</h3><p>First-time building a business is hard work, which requires a long-term commitment. I would like to see more people doing it, and I hope that my sharing my progress can inspire you to start something of your own.</p><p>It’s exciting to look at your business as a living, breathing thing that keeps growing every time. Once you start doing <em>something</em>, new opportunities and ideas start coming. I’m excited by what my little tea business <em>could</em> become, and I’m willing to see it through.</p><p>The most important takeaways from the last 6 months are:</p><ul><li><strong>Do things that don’t scale</strong> — I neglected this part, and I’m only now realizing its importance. In my case, it’s direct sales.</li><li><strong>Focus on providing a great experience to existing customers</strong> — me chatting and building a relationship with Jesse has gained me a <em>fan.</em> Even if your customers are your family and friends — make sure they become your fans.</li><li><strong>Don’t try to do everything yourself </strong>— that may not be possible on a tight budget, but generally, try to outsource the work to others. I like having control over what I put out, and sometimes I think only I can do things the way I want — but that stunts the progress significantly. I’m learning to let it go, and I recommend you do it too.</li></ul><p>Let me know if you would like me to keep sharing the progress. It’s motivating to hear from people who read the articles. If you wish to contact me or give feedback, feel free to do it in the comments or on <a href="https://twitter.com/vincaslt">Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b230dbb1c8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why I Sell Tea as a Software Engineer]]></title>
            <link>https://vincasstonys.medium.com/why-i-sell-tea-as-a-software-engineer-b904504e6527?source=rss-c8cc74215403------2</link>
            <guid isPermaLink="false">https://medium.com/p/b904504e6527</guid>
            <category><![CDATA[shopify]]></category>
            <category><![CDATA[side-hustle]]></category>
            <category><![CDATA[tea]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[motivation]]></category>
            <dc:creator><![CDATA[Vincas Stonys]]></dc:creator>
            <pubDate>Sun, 29 Aug 2021 19:22:26 GMT</pubDate>
            <atom:updated>2022-03-02T10:37:44.479Z</atom:updated>
            <content:encoded><![CDATA[<p>Let me tell you a recipe for success, that I’ve learned throughout my life:</p><ol><li>Do well in school;</li><li>Go to a good university;</li><li>Find a well-paid job and work 9–5 for 40 years.</li></ol><p>You’ve heard this too, right? And, like me, you probably thought —<em> this can’t be right</em>. So why do so many of us live our lives like that <em>is</em> true?</p><p>I live a model life of a successful young man. I’m no millionaire, sure, but I make my aunties proud — I have so far been executing the above steps flawlessly.</p><p>As a child, I’ve been called wunderkind because of my desire to learn and question everything. I learned to read and count way before I started school (like a real-life Matilda). I didn’t put much effort into studying in school, but I still did well. I graduated with the top 50 final exam results in Lithuania that year. I went to the best university in my country, and I’m already well advanced in my Software Engineering career.</p><p>Yet,<em> I feel like I’m spinning wheels</em>.</p><p>The more conventional success I seem to achieve, the more frustrated I feel. I’ve changed 4 jobs already in search of “the one”. I learned that most of the corporate world is governed by superficial things like people’s egos. And realized that school hasn’t given me the skills necessary to build something of my own.</p><p>Identity crisis hit hard when I realized that I will not be able to sustain this kind of life. I don’t enjoy working on somebody else’s terms or solving somebody else’s problems. Only to be left with nothing if I quit or take a break. Daniel Vassallo sums it up well:</p><h3>Daniel Vassallo on Twitter: &quot;I&#39;m convinced that working 40hr/wk, 50 weeks per year, for 30-40 straight years, is against our nature.Yet, the most skilled, educated, and highly paid people I know tend to be unable to consider any other path that doesn&#39;t involve enduring this artificial lifestyle. / Twitter&quot;</h3><p>I&#39;m convinced that working 40hr/wk, 50 weeks per year, for 30-40 straight years, is against our nature.Yet, the most skilled, educated, and highly paid people I know tend to be unable to consider any other path that doesn&#39;t involve enduring this artificial lifestyle.</p><p>Over the last years, I read a dozen of self-help books, listened to lectures from life coaches and therapists, and pondered a lot. If nothing else, I realized, that nobody ever comes to you with the answer. It’s an individual responsibility to figure out how to build wealth or how to find what makes you happy. Selling time for money or status at a day job doesn’t achieve either.</p><p>I’m not going to focus as much on trying to advance my career anymore, but rather to build something of my own. I will try to build a side-business, while still working full-time. By writing about my journey as it evolves, I wish to inspire you to start searching for your own path too.</p><h3>Attempts at building software</h3><p>You may be thinking — <em>hey, I get it, you’re fed up with the job, but you’re a software engineer, build a software product</em>. And that’s a reasonable proposition.</p><p>I’ve made a few attempts at creating software on my own, but I always hit a wall, when other skills need to come into play. Most notably — marketing. I would get a user here and there, but I could never get real traction. I would abandon the project and start something else soon after.</p><p>Sure, I could persevere. I could try to collect feedback and improve the product or marketing, but after 3–6 months of working, I rarely have the motivation left to keep at it. Especially, because the problems I take on are usually not the ones I‘ve had myself. Essentially, it ends up feeling as if I’m working at a day job, <em>for which I don’t get paid</em>.</p><p>I’ve learned the hard way, that it’s not enough to create a good product. You also need to put yourself out there: <em>be confident, take some risks, put your ego on the line</em>. People won’t come if they don’t know about you. It doesn’t serve well to be a timid introvert like me. Even though this behavior doesn’t come naturally, that is not to say it can’t be learned.</p><p>Trying to build software products hasn’t been a wasted effort though. It showed me areas I need to improve — <strong>marketing skills</strong> and <strong>my character.</strong> I figured it would be more efficient to do that in isolation, without the distraction of building a complex product. Selling a commodity seems to be, mostly, a marketing effort, so I only needed to figure out what to sell.</p><h3>Becoming a tea planter</h3><p>I’ve always enjoyed tea. But ever since I ordered some high-quality loose-leaf tea, I’ve been hooked. I‘m continually impressed with how diverse the tea world is and I want to keep learning more about it. It became my passion.</p><p>It’s important to have grand goals — an audacious vision. <em>What is mine you ask?</em> I want to own a tea plantation. Something is alluring in the thought of strolling my tea fields and drinking freshly plucked tea in the morning.</p><p>Granted, I’m far off from being a tea planter, but I imagine the steps being:</p><ol><li>Build a tea brand online — to learn marketing skills, learn about tea, and how to run a business.</li><li>Open a physical tea shop — to learn how to manage a physical location and other people.</li><li>Acquire a stake in a tea plantation business — to get involved in running a plantation, but have someone experienced help me.</li></ol><h4>Finding the right tea</h4><p>I allocated a budget of €1000 (~1200$) to start the online tea shop. For several months I’ve been contacting wholesale tea suppliers asking for samples. It surprised me how willing they were to send me their tea. Also, <em>I enjoyed the process</em>.</p><blockquote>A tip: if you want an almost unlimited high-quality tea for free, message tea suppliers and ask for samples.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*0SPk9E4bGMLP_9ca" /><figcaption>One of the batches of tea samples from a supplier.</figcaption></figure><p>I tried 4 different suppliers. Half of my kitchen drawers are now filled with tea samples and I tasted over 50 different teas. In the end, I picked the three variants I preferred:</p><ol><li>An English breakfast variant</li><li>An Earl Grey variant</li><li>A strong black tea variant known as East Frisian.</li></ol><p>I put in the order for 2 kilograms of each tea with my supplier. In the meantime, I needed to think of a name, figure out packaging, and set up an online store.</p><p>I first toyed with the idea of branding as some sort of a modern take on tea, but it didn’t feel authentic to me. Another thought was to brand around people’s identities that they create for themselves (e.g. book nerd, tea lover), but it seemed too vague.</p><p>Then I came back to basics, and asked myself — <em>why did I start drinking loose-leaf tea in the first place?</em> I liked the simplicity of tea bags, but I wanted to replace them with higher-quality tea. The problem is, I am no tea expert and I can get overwhelmed by hundreds of different tea variants available. So… I will create a simple loose-leaf tea replacement for tea bags, for other people like me.</p><h4>Creating a product</h4><p>Picking a good name turned out to be more difficult than it seemed. Initially, I tried combining different words associated with tea. Then I tried words that simply sounded cool, but I never felt any connection to any of the names. My girlfriend cheekily called my tea by a cute name she has for me — and I thought, <em>that’s it</em>.</p><p>I gave it a minor tweak so it seemed like a combination of my first name and last name and called it — <a href="https://vistontea.com/"><strong>Viston Tea</strong></a>. I could feel the personal connection to the name, and <em>it sounded good</em>, so I stuck with it.</p><p>If you’d asked me to draw something — you’d likely think I was 5 years old, judging by my artwork. Also, I decided I wouldn’t try and do <em>everything</em> by myself. So I needed somebody to design me a logo.</p><p>I found a designer on Fiverr and took the advice of many online reviews, not to pick the cheapest option. I paid €112 (~130$) for the design, and even then it was hard to convey what I needed.</p><blockquote><em>To get the most from Fiverr, don’t pick the cheapest option. Choose a designer offering multiple revisions, and be clear about your concept and requirements.</em></blockquote><p>Because I didn’t have a concrete idea of what I wanted, there was a lot of back and forth. Yet, the guy was helpful with multiple revisions, and in the end, we came up with the design I was fine with. I tweaked the colors myself and I had my logo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/1*sTGalerAPvymVs7pnaP8ig.png" /><figcaption>My edited Logo for <a href="https://vistontea.com/">Viston tea</a>.</figcaption></figure><p>Early on, I decided I would only sell loose-leaf tea, and usually, they come in stand-up pouches. First, I wanted to have my designs be printed on the pouches themselves. Turns out, it’s hard to find anyone to print low quantities without breaking the bank. I decided to print only the label stickers and order the pouches from AliExpress.</p><p>A year ago, when I was looking for inspiration for the visual editor tool I was building, I discovered Canva. It impressed me with how quickly you can get a good-looking design using their templates. I spent a weekend designing front and back labels for my teas. After a bit of a back and forth with printing companies I finally put in an order for my label stickers. Here’s how they look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nzqo-1CCfytMeFoBx9_enA.png" /><figcaption>One of the labels I designed for my tea.</figcaption></figure><p>With all the components together, I had the product. Now I only needed an online shop.</p><h4>Opening an online store</h4><p>Setting up an online store wasn’t difficult. I wasn’t going to reinvent the wheel, so I chose Shopify as my platform. I spent a hundred bucks on a custom theme and set it up. The scary parts are taxes and shipping. I found some basic information online but decided to figure out the rest as I go. Here’s the result: <a href="https://vistontea.com/">https://vistontea.com</a></p><p>The rest was straightforward —I set up my payment provider, took product photos, and priced each item at €8.95. It would leave me with a few euros in profit for every item. And with that, I was ready to launch.</p><p>I’m a bit ashamed it took me almost a month to set it up. I was afraid to miss something crucial and had to keep fighting my urge to figure out every detail. It’s part of the learning progress though.</p><p>I opened my shop for the public and promoted it the only ways I knew how:</p><ul><li>shared with friends, which netted me 3 sales,</li><li>spammed some Facebook groups and posted on social media,</li><li>wrote a Reddit post.</li></ul><p><em>See?</em> Now you know why said I needed to learn about marketing. I used to catch myself thinking — <em>I’ll build something, and thousands of people will come right away</em>. Now I hit the same wall I hit with any other product I build — very few people visit my shop. But this time I want to break through that wall.</p><h4>What’s next?</h4><p>I’ve identified these areas I need to improve:</p><ol><li><strong>Ensure a steady stream of qualified leads</strong>. I can’t build in a vacuum. If nobody is visiting the store, nobody is going to buy anything.</li><li><strong>Larger product selection</strong>. I only have 3 black teas, and that’s a very small selection. I will need to get it up to at least 10 different teas.</li><li><strong>Set up my conversions funnel</strong>. There are countless plugins and optimizations that could increase conversion.</li></ol><p>The most important thing right now is to get a consistent stream of qualified traffic to the shop. If I can’t do that, nothing else will matter. As I see it, there are several ways I could do that:</p><ol><li><strong>Ads</strong> — I don’t have a large budget and I’m not a good copywriter, so setting up ads to drive traffic seems risky.</li><li><strong>Community </strong>— I don’t belong to any community in my niche. That’s something I could work on, but it’s unclear to me how to approach learning it at the moment.</li><li><strong>Content marketing </strong>— There’s a lot to talk about tea, so it seems like a great way to build up traffic.</li></ol><p>So my plan for the next month is to <strong>set up a blog, write 4–5 articles and promote them</strong>. By promoting those articles I expect to get some steady traffic to my blog and start building SEO. In turn, some of the traffic should trickle down to the shop. Later, I can set up a conversions funnel on the blog to get qualified leads to my tea shop.</p><h4>Conclusion</h4><p>I want to break out of the endless grind of the day job and build something of my own that lasts. I have started an online tea shop and have a vision of owning a tea plantation at some point.</p><p>Building a business is as much of a character test as a skill. I want to prove to myself that I can build something of my own, outside of my day job as a software engineer. I view this experiment as a crash course in running a business that costs €1000. Even if I fail, I will be happy to have learned a lot.</p><p>I will be sharing monthly updates of my progress and setting goals for the following months. For the next month, my goal is to break through the wall I always kept facing and learn to build traffic to my shop. After that, I will be able to focus on increasing my product selection and optimizing the store.</p><p>If everything goes well, in the future I hope to own a tea plantation and a few small tea shop locations. I invite you to follow my journey here on Medium or on <a href="https://twitter.com/vincaslt">Twitter</a>, where I will be sharing updates. Hopefully, by sharing my learnings I can teach you something, and inspire you to build something of your own.</p><p><em>What have you always wanted to build, but haven’t yet? What’s been stopping you?</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b904504e6527" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Promoting your podcast on social media with Canva and Audiograms]]></title>
            <link>https://vincasstonys.medium.com/promoting-your-podcast-on-social-media-with-canva-and-audiograms-243e14bc35a?source=rss-c8cc74215403------2</link>
            <guid isPermaLink="false">https://medium.com/p/243e14bc35a</guid>
            <category><![CDATA[podcasting]]></category>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[podcasting-tips]]></category>
            <category><![CDATA[podcasting-101]]></category>
            <category><![CDATA[marketing]]></category>
            <dc:creator><![CDATA[Vincas Stonys]]></dc:creator>
            <pubDate>Sat, 24 Apr 2021 14:42:41 GMT</pubDate>
            <atom:updated>2021-04-24T14:42:41.784Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the most frustrating, but important tasks when podcasting is finding your listener. In the era of social media it obvious that you must build an audience on sites like twitter, facebook, instagram and engage with your listeners. However, simple promotional tweets go by unnoticed in your potential listeners’ feeds. The good news is that now, more than ever, it’s easier to make your podcast grab attention with an audiogram.</p><h3>What is an audiogram?</h3><p>The inherent issue with promoting your podcast on social media is that it’s impossible (yet) to share audio clips. And posting a link or an image is much less engaging.</p><blockquote>“On Twitter, the average engagement for an audiogram is 8x higher than a non-audiogram tweet and on Facebook some of our shows are seeing audiogram reach outperform photos and links by 58% and 83% respectively.” — @WNYC <a href="https://link.medium.com/li6BThzBIfb">https://link.medium.com/li6BThzBIfb</a></blockquote><p>To work around this, people have been creating videos for their audio content. You may have seen promotional posts on social media with image and an audiogram (graphic patterns reacting to audio). This is what this article will teach you to create for your own podcast.</p><h3>Creating podcast artwork</h3><p>If you already have a social media ready artwork, you can skip this step. However, chances are you are not a professional designer, and if you’re just starting, you don’t have custom artwork.</p><p>You can make it easy on yourself — make use of Canva’s pre-made templates and customize it to your needs, or start with a pre-designed template if you have it already. In this article I chose a template for an instagram post. Once you have the artwork ready, simply download a PNG image and save it on your computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-7QRobaSTC1RNEl9uyiB-Q.png" /><figcaption>Customizing a pre-made template on Canva</figcaption></figure><h3>Adding an audiogram</h3><p>Here you could create an audiogram yourself with a tool like Adobe Premiere, or hire somebody to do that for you on Fiverr. However, there are online tools that can do this. In this article we will use <a href="https://mediabits.io/">mediabits.io</a>.</p><p>First we will upload the artwork we created previously on Canva — add an image element onto the screen and position it in the center. Mediabits also offers animated elements, like — waveform that reacts to the audio and progress bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3atvcrZoBWhzSbxilimEQ.png" /><figcaption>Importing Canva artwork to mediabits.io</figcaption></figure><p>Now upload an audio clip of a highlight from your podcast, or the whole episode (you can trim it in the application if it’s under 50MB). Then, click on “Generate video” and wait a bit for your video to get processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9HNXy4rH3yN0Pd0FlpFHcw.png" /><figcaption>Trimming the uploaded audio clip</figcaption></figure><h3>Promote the clip on social media</h3><p>At the end of this process you will have received a link to your video. You can download and save the video to your computer. Now go to the social media site of your choice and make a post!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*LDvy9tDc9xMnygDMM0UasQ.png" /><figcaption>Tweet with the video we created using Canva and mediabits.io</figcaption></figure><h3>Conclusion</h3><p>You can increase engagement of your podcast’s promotional posts if you include a video instead of an image or a link. In this article we showed how easily you can create great videos, people will notice, in a matter of minutes.</p><p>Experiment with templates and options on Canva and mediabits.io to get the most out of it. You will soon realize, that hiring a professional designer may not be necessary.</p><p>If you want to ask a question, tweet at me @vincaslt on twitter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=243e14bc35a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DIY: React+TypeScript Input Validations]]></title>
            <link>https://vincasstonys.medium.com/diy-1-react-typescript-input-validations-c8d833926300?source=rss-c8cc74215403------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8d833926300</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Vincas Stonys]]></dc:creator>
            <pubDate>Sun, 23 Sep 2018 18:47:03 GMT</pubDate>
            <atom:updated>2022-04-11T11:57:21.658Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Note: This article is a bit outdated, but the code should still work. I sell tea now. Get some for yourself or your office from <a href="https://vistontea.com/">vistontea.com</a>.</blockquote><p><em>I explain my thought process while writing solutions for common problems that we tend to seek libraries for. First challenge — input field validation in React.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*zZLybj0HlAKtdSXQhgdegw.png" /></figure><p>JavaScript has exploded in popularity over the last few years, so naturally, there are more and more developers trying their hand at front-end development, and this is great for the community. However, the cost of this immense popularity is that it seems there are libraries for virtually anything. Because of how easy it is to pull a dependency into our own project, some of us forget how to solve even simple problems ourselves. In articles of this series I will explain my thought process while writing solutions for common problems that we tend to seek libraries for, when in fact, we could write them on our own relatively simply. So to begin, let’s take on a challenge, that virtually all web applications must have at some point: <em>input field validation</em>.</p><p>Since my hammer of choice is React, all of the example code will be written for it. I will also use TypeScript for the examples, but if you prefer plain JavaScript, just remove type declarations and it should work fine; honestly though, if you are still using plain JavaScript in 2018 for serious projects, you are totally missing out ;)</p><h4>Designing an API</h4><p>Before we begin with the code, it is helpful to define what our task is. Generally, <strong>validation allows us to show error messages when the field’s current value doesn’t satisfy some criteria.</strong></p><p>The very first step is to define an input. I believe in the <a href="https://en.wikipedia.org/wiki/Separation_of_concerns">separation of concerns</a>, and validation is not the input’s responsibility in my opinion. Input on its own should be very simple, and any other complex functionality should be decorated on top of it. We can use a <a href="https://reactjs.org/docs/higher-order-components.html">higher-order component</a> to add validation functionality to the inputs in a modular way. However, the error state is not necessarily part of the validation, because it is closely coupled with the input’s own style and also it could come from other places, like back-end or form validation. So we will need to create:</p><ul><li><em>Input</em> — a generic input that has two states — error and default.</li><li><em>withValidation </em>— higher-order component responsible for validating the input and passing it the error message.</li></ul><p>The most basic input could be written as such:</p><pre>// Input.tsx</pre><pre>import * as React from &quot;react&quot;;</pre><pre>interface InputProps<br>  extends React.InputHTMLAttributes&lt;HTMLInputElement&gt; {<br>  error?: string;<br>}</pre><pre>const Input = ({ error, ...rest }: InputProps) =&gt; (<br>  &lt;div&gt;<br>    &lt;input {...rest} /&gt;<br>    {error &amp;&amp; &lt;div&gt;{error}&lt;/div&gt;}<br>  &lt;/div&gt;<br>);</pre><pre>export default Input</pre><p>It is basically the default HTML input but supports an error message if it’s passed.</p><p>Another important building block is the actual <em>validator </em>— a function responsible for validating the input’s value. In its simplest form it can be defined as a function that returns a string error message if the value is invalid, if no error message is returned, it is safe to assume the validation has passed:</p><pre>value =&gt; error | undefined</pre><p>It is now possible to theoretically define validated inputs as a combination of:</p><pre>Input + withValidation + validators</pre><p>Let&#39;s write a basic usage example that illustrates that, i. e. password input that has a minimum length requirement of at least 8 symbols, and a combination of numbers and letters:</p><pre>// PasswordInput.tsx</pre><pre>import withValidation from &quot;./WithValidation&quot;;<br>import Input from &quot;./Input&quot;;</pre><pre>const requiredValidator = (value?: string) =&gt;<br>  !value ? &quot;Required&quot; : undefined;</pre><pre>const minLengthValidator = (value?: string) =&gt;<br>  value &amp;&amp; value.length &lt; 8 ? &quot;Too short&quot; : undefined;</pre><pre>const difficultyValidator = (value?: string) =&gt;<br>  value &amp;&amp; !/^(?=.*\d)(?=.*[A-Za-z]).*$/.test(value)<br>    ? &quot;Must contain at least one number and letter&quot;<br>    : undefined;</pre><pre>const PasswordInput = withValidation(Input, [<br>  requiredValidator,<br>  minLengthValidator,<br>  difficultyValidator<br>]);</pre><pre>export default PasswordInput;</pre><p>Notice how simple it is to define different types of inputs only once when thinking in terms of the formula. Also, minimum length implicitly has “required” validation already, but I decided to extract it separately, because I think validators should have as narrow a scope as possible, any more complex validation should be composed of several such validators. That allows better separation of concerns and gives greater control over error messages and which validator is run when.</p><h4>Implementing the solution</h4><p>With the basic API in place, the next step is to try and implement it. The task now is pretty straightforward:</p><ol><li>Write the higher-order component accepting the input and validators.</li><li>When rendering we run the validators until one of them returns an error message, or all of them are done.</li><li>Pass the error to the original input.</li></ol><p>Since the example is for TypeScript, I will first define the relevant types:</p><pre>// WithValidation.tsx</pre><pre>type ValueType = string | number | string[];<br>type ValidatorType = (value?: ValueType) =&gt; string | undefined;</pre><pre>interface RequiredInputProps {<br>  error?: string<br>  value?: ValueType<br>};</pre><p>They are just the formal definitions of input value types and validators. The actual input props will extend RequiredInputProps, this way I’m sure error and value are defined in the way this component supports. Now it’s time to write the actual higher-order component implementation:</p><pre>// WithValidation.tsx</pre><pre>function withValidation&lt;InputProps extends RequiredInputProps&gt;(<br>  InputComponent: React.ComponentType&lt;InputProps&gt;,<br>  validators: ValidatorType[] = []<br>) {<br>  return class InputWithValidation extends React.Component&lt;<br>    InputProps<br>  &gt; {<br>    render() {<br>      const { error, value } = this.props;</pre><pre>const firstInvalidValidator = validators.find(<br>        validate =&gt; !!validate(value)<br>      );</pre><pre>const validationError =<br>        firstInvalidValidator &amp;&amp; firstInvalidValidator(value);</pre><pre>return (<br>        &lt;InputComponent<br>          {...this.props}<br>          error={error || validationError}<br>        /&gt;<br>      );<br>    }<br>  };<br>}</pre><pre>export default withValidation;</pre><p>This is the most primitive implementation I can imagine. The decorator accepts the actual input and validators. In the render method, it runs all of the validators to find the first one returning the error message. That same validator is run again to get the error and pass it to the input component. I have left the ability to override the error message that validators have found, so I haven’t taken away any existing functionality from the input, just added a new one — validation.</p><p>Let’s put what we already have together and see how it works:</p><pre>// App.tsx</pre><pre>import * as React from &quot;react&quot;;<br>import withValidation from &quot;./WithValidation&quot;;<br>import PasswordInput from &quot;./PasswordInput&quot;;</pre><pre>interface State {<br>  value?: string;<br>}</pre><pre>class App extends React.Component&lt;{}, State&gt; {<br>  state: State = {<br>    value: undefined<br>  };</pre><pre>changeHandler = (evt: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt;<br>    this.setState({ value: evt.currentTarget.value });</pre><pre>render() {<br>    return (<br>      &lt;PasswordInput<br>        type=&quot;password&quot;<br>        onChange={this.changeHandler}<br>        value={this.state.value}<br>      /&gt;<br>    );<br>  }<br>}</pre><pre>export default App;</pre><p>Here is the interactive example and code of what has been done yet:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F61z8r4o4wk&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F61z8r4o4wk&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F61z8r4o4wk%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/708fb99631869752d403ebe637c4a2d3/href">https://medium.com/media/708fb99631869752d403ebe637c4a2d3/href</a></iframe><p>It is simple and it works, but you may notice there are several problems, I will address them now.</p><h4>Problem: field is validated immediately</h4><p>This issue has two sides: we can see it has an error already when it’s first rendered, and another, an error message is shown and changed when typing. This behavior is not ideal and I’ll try to improve it now.</p><p>Both of these problems can be solved by introducing<em> </em>a new state to the input which I will call <em>finalized. </em>It will be true when the field has been finished editing. For that, I will set it to false initially and on every keystroke. I will set it to true when the input loses focus. The only thing left is to type that out:</p><pre>/// WithValidation.tsx</pre><pre>import * as React from &quot;react&quot;;</pre><pre>type ValueType = string | number | string[];<br>type ValidatorType = (value?: ValueType) =&gt; string | undefined;</pre><pre>interface RequiredInputProps {<br>  onChange?: React.ChangeEventHandler&lt;HTMLInputElement&gt;;<br>  onBlur?: React.FocusEventHandler&lt;HTMLInputElement&gt;;<br>  error?: string;<br>  value?: ValueType;<br>}</pre><pre>interface ValidatedInputState {<br>  finalized: boolean;<br>}</pre><pre>function withValidation&lt;InputProps extends RequiredInputProps&gt;(<br>  InputComponent: React.ComponentType&lt;InputProps&gt;,<br>  validators: ValidatorType[] = []<br>) {<br>  return class InputWithValidation extends React.Component&lt;<br>    InputProps,<br>    ValidatedInputState<br>  &gt; {<br>    state: ValidatedInputState = {<br>      finalized: false<br>    };</pre><pre>handleChange = (e: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; {<br>      this.setState({ finalized: false });<br>      if (this.props.onChange) {<br>        this.props.onChange(e);<br>      }<br>    };</pre><pre>handleBlur = (e: React.FocusEvent&lt;HTMLInputElement&gt;) =&gt; {<br>      this.setState({ finalized: true });<br>      if (this.props.onBlur) {<br>        this.props.onBlur(e);<br>      }<br>    };</pre><pre>render() {<br>      const { error, value } = this.props;</pre><pre>const firstInvalidValidator = validators.find(<br>        validate =&gt; !!validate(value)<br>      );</pre><pre>const validationError =<br>        this.state.finalized &amp;&amp; firstInvalidValidator<br>          ? firstInvalidValidator(value)<br>          : undefined;</pre><pre>return (<br>        &lt;InputComponent<br>          {...this.props}<br>          onChange={this.handleChange}<br>          onBlur={this.handleBlur}<br>          error={error || validationError}<br>        /&gt;<br>      );<br>    }<br>  };<br>}</pre><pre>export default withValidation;</pre><p>I have added two methods <em>handleBlur </em>and <em>handleChange </em>and passed them to the original input component. They toggle the <em>finalized </em>flag accordingly. I’ve also added a safeguard to the methods so that the original <em>onBlur </em>and <em>onChange </em>are called and no input functionality is lost. The only other thing I did is the condition to set <em>validationError </em>only when the input is finalized (the external error is still shown no matter what, to keep the original input functionality). As a result of the changes, the error is shown only when the user has finished typing.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F3q63lxp696&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F3q63lxp696&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F3q63lxp696%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c488cbf8a6656b89e297dfd708d46376/href">https://medium.com/media/c488cbf8a6656b89e297dfd708d46376/href</a></iframe><p>There is still one subtle problem left though…</p><h4>Problem: handling dynamic validation</h4><p>The validation in the current stage is usable as is, but consider one, not-so-uncommon use case — password confirmation. It basically requires us to validate the value against another input’s value, but our input is only created once with some predefined validators. It may seem like the solution is to just create a new input every time we render it, this way the new validator could be passed every time we render the component, but this does not work:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F425lnmm494&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F425lnmm494&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F425lnmm494%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/cccde9c51e9b079bb951cb8538983233/href">https://medium.com/media/cccde9c51e9b079bb951cb8538983233/href</a></iframe><p>As you can see, newly created input loses all state that it had on every re-render, along with the focus it had. This solution would be fragile anyway, so scratch that. There is a ridiculously simple solution — we can just use props to pass in additional validators, like so:</p><pre>// WithValidation.tsx</pre><pre>import * as React from &quot;react&quot;;</pre><pre>type ValueType = string | number | string[];<br>type ValidatorType = (value?: ValueType) =&gt; string | undefined;</pre><pre>interface RequiredInputProps {<br>  onChange?: React.ChangeEventHandler&lt;HTMLInputElement&gt;;<br>  onBlur?: React.FocusEventHandler&lt;HTMLInputElement&gt;;<br>  error?: string;<br>  value?: ValueType;<br>}</pre><pre>interface ValidatedInputProps {<br>  validators?: ValidatorType[];<br>}</pre><pre>interface ValidatedInputState {<br>  finalized: boolean;<br>}</pre><pre>function withValidation&lt;InputProps extends RequiredInputProps&gt;(<br>  InputComponent: React.ComponentType&lt;InputProps&gt;,<br>  staticValidators: ValidatorType[] = []<br>) {<br>  return class InputWithValidation extends React.Component&lt;<br>    InputProps &amp; ValidatedInputProps,<br>    ValidatedInputState<br>  &gt; {<br>    state: ValidatedInputState = {<br>      finalized: false<br>    };</pre><pre>handleChange = (e: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; {<br>      this.setState({ finalized: false });<br>      if (this.props.onChange) {<br>        this.props.onChange(e);<br>      }<br>    };</pre><pre>handleBlur = (e: React.FocusEvent&lt;HTMLInputElement&gt;) =&gt; {<br>      this.setState({ finalized: true });<br>      if (this.props.onBlur) {<br>        this.props.onBlur(e);<br>      }<br>    };</pre><pre>render() {<br>      const { error, value, validators = [] } = this.props;</pre><pre>const firstInvalidValidator = [<br>        ...validators,<br>        ...staticValidators<br>      ].find(validate =&gt; !!validate(value));</pre><pre>const validationError =<br>        this.state.finalized &amp;&amp; firstInvalidValidator<br>          ? firstInvalidValidator(value)<br>          : undefined;</pre><pre>return (<br>        &lt;InputComponent<br>          {...this.props}<br>          onChange={this.handleChange}<br>          onBlur={this.handleBlur}<br>          error={error || validationError}<br>        /&gt;<br>      );<br>    }<br>  };<br>}</pre><pre>export default withValidation;</pre><p>I have renamed our previous <em>validators </em>parameter to <em>staticValidators</em>, and added a new prop that the decorated input will accept called <em>validators</em>. In the render method, I just combine the two arrays and that’s it!</p><p>This is quite clever I think, because now if our dynamic validator is defined in the form:</p><pre>value1 =&gt; value2 =&gt; string | undefined</pre><p>it is possible to partially call this validator. Essentially, a new validator will be created for every different value it needs to check against, triggering the validation when another input’s value is changed. Let’s test this approach:</p><pre>// App.tsx</pre><pre>import * as React from &quot;react&quot;;<br>import withValidation from &quot;./WithValidation&quot;;<br>import PasswordInput from &quot;./PasswordInput&quot;;<br>import Input from &quot;./Input&quot;;</pre><pre>interface State {<br>  password?: string;<br>  passwordConfirmation?: string;<br>}</pre><pre>const PasswordConfirmationInput = withValidation(Input);</pre><pre>class App extends React.Component&lt;{}, State&gt; {<br>  state: State = {<br>    password: undefined,<br>    passwordConfirmation: undefined<br>  };</pre><pre>passwordChangeHandler = (<br>    evt: React.ChangeEvent&lt;HTMLInputElement&gt;<br>  ) =&gt; this.setState({ password: evt.currentTarget.value });</pre><pre>passwordConfirmationChangeHandler = (<br>    evt: React.ChangeEvent&lt;HTMLInputElement&gt;<br>  ) =&gt;<br>    this.setState({ passwordConfirmation: evt.currentTarget.value });</pre><pre>render() {<br>    const samePasswordValidator = (password?: string) =&gt; (<br>      passwordConfirmation?: string<br>    ) =&gt;<br>      password !== passwordConfirmation<br>        ? &quot;Passwords do not match&quot;<br>        : undefined;</pre><pre>return (<br>      &lt;div&gt;<br>        &lt;PasswordInput<br>          type=&quot;password&quot;<br>          onChange={this.passwordChangeHandler}<br>          value={this.state.password}<br>        /&gt;<br>        &lt;PasswordConfirmationInput<br>          type=&quot;password&quot;<br>          onChange={this.passwordConfirmationChangeHandler}<br>          value={this.state.passwordConfirmation}<br>          validators={[samePasswordValidator(this.state.password)]}<br>        /&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><pre>export default App;</pre><p>I’ve created a password confirmation input that has validation functionality, but no validators on its own. The only validator is passed as a prop and it checks the input’s value against the password. As I’ve mentioned before, the new validator is created for every value:</p><pre>samePasswordValidator(this.state.password)</pre><p>and this triggers the re-render of password confirmation input, which in turn triggers the validation. Here’s the finished solution:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fm386mwz5yy&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fm386mwz5yy&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fm386mwz5yy%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a29631fffa6bb7d859380cbeae510f14/href">https://medium.com/media/a29631fffa6bb7d859380cbeae510f14/href</a></iframe><h4>Conclusion</h4><p>Using a structured approach to problem-solving, I was able to implement my own solution to basic input validation needs. To achieve this</p><ol><li>I have defined what the main task is;</li><li>I have sketched out the API that solves the problem;</li><li>I have built the implementation for the API;</li><li>I have identified problems with the solution;</li><li>Repeat from step 1;</li></ol><p>I believe in using an iterative approach to problem-solving because it’s very hard to predict all the potential pitfalls.</p><p>In the end, this is still not the ideal solution — it validates inputs, but there may be some challenges when complex form validation is involved. Also, the inputs used in the example are very primitive. In larger codebases inputs may be more complex, and even using the same modular approach to extending input’s functionality, some incompatibilities may need to be patched. But as I like to say — let’s not solve problems that we don’t yet have.</p><p>My point is — that I did not need a separate library to handle input validation. I faced some challenges and made solutions to them. I’m not against using libraries for such things, but I didn’t need to, and when I actually do need to, I will know what problems they solve, and why I need them solved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8d833926300" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>