<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michael Grechka</title>
    <description>The latest articles on DEV Community by Michael Grechka (@grech_ca).</description>
    <link>https://dev.to/grech_ca</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F583253%2F5df6303b-086b-430a-9ef7-9cbcb928a0af.png</url>
      <title>DEV Community: Michael Grechka</title>
      <link>https://dev.to/grech_ca</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/grech_ca"/>
    <language>en</language>
    <item>
      <title>How Crash Courses Can Hold You Back</title>
      <dc:creator>Michael Grechka</dc:creator>
      <pubDate>Mon, 09 Sep 2024 21:29:43 +0000</pubDate>
      <link>https://dev.to/grech_ca/how-crash-courses-can-hold-you-back-4h32</link>
      <guid>https://dev.to/grech_ca/how-crash-courses-can-hold-you-back-4h32</guid>
      <description>&lt;p&gt;Read the post in Telegram: &lt;a href="https://t.me/mike_in_web/5" rel="noopener noreferrer"&gt;https://t.me/mike_in_web/5&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I started learning frontend, like a lot of people, I went through different tutorials and courses where the goal was to build some kind of project. The problem with this approach is that you're handed a solution.&lt;/p&gt;

&lt;p&gt;You don't really get the chance to think things through or figure them out on your own, so you end up in a situation where, yeah, you know how to do something, but your skills become so narrow that if you're asked to do anything slightly different, you fall apart over the simplest stuff. In the end, instead of becoming a web developer, you turn into a “to-do list master,” building the same app over and over, just following the video like a script.&lt;/p&gt;

&lt;p&gt;But when you work on a personal project, you’re the one asking the questions: “How do I make this work?” And that’s when real learning kicks in. You’ve got a need, you hit roadblocks, and you end up "reinventing the wheel." Your interest and motivation come naturally because every feature actually matters to you. And then, the best part of learning happens — those "Aha!" moments 😮.&lt;/p&gt;

&lt;p&gt;It’s when you hit those roadblocks that you finally think, “Ah! So that’s what [insert tech here] is for,” or “Now I get why you’re supposed to do it this way!” It’s not just some empty lesson you learned because “that’s just how it’s done.”&lt;/p&gt;

&lt;p&gt;And what’s cool is that these kinds of projects really help during interviews. You’re not just showing off some tutorial code; you’re showcasing solutions you came up with on your own. That immediately sets you apart from the people who just churned through a course.&lt;/p&gt;

&lt;p&gt;So don’t just follow someone else’s plans. Solve your own problems, and your learning will be way more interesting 💫.&lt;/p&gt;

&lt;p&gt;Follow me in Telegram: &lt;a href="https://t.me/mike_in_web" rel="noopener noreferrer"&gt;https://t.me/mike_in_web&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>learning</category>
    </item>
    <item>
      <title>Is it too late to become a web developer in X year? 🤔</title>
      <dc:creator>Michael Grechka</dc:creator>
      <pubDate>Sat, 07 Sep 2024 22:38:00 +0000</pubDate>
      <link>https://dev.to/grech_ca/is-it-too-late-to-become-a-web-developer-in-x-year-5bp6</link>
      <guid>https://dev.to/grech_ca/is-it-too-late-to-become-a-web-developer-in-x-year-5bp6</guid>
      <description>&lt;p&gt;When I started learning web development back in 2019, I had the same doubts as everyone else. Even then, website builders were around, and people were already saying (oh no!) that they’d replace all web developers. This concern was always there, but it didn’t stop me from exploring the world of development.&lt;/p&gt;

&lt;p&gt;By 2020, when I was finally making some progress, WebAssembly was starting to gain traction. People said it could make front-end developers obsolete by letting programmers compile languages like C# into WASM, so you could have a website written entirely in C#. Why bother learning JavaScript, right?&lt;/p&gt;

&lt;p&gt;Then, in 2021, I noticed mobile development taking off, especially with Flutter. It seemed like you could build cross-platform apps for anything, including the web. That made me wonder if websites would even be needed anymore, with mobile apps growing so fast.&lt;/p&gt;

&lt;p&gt;In 2022, GitHub Copilot arrived and scared everyone who saw it. Who would’ve thought a programmer could just write plain English, and the program would generate the code automatically? Yet here we are, and the world didn’t end.&lt;/p&gt;

&lt;p&gt;Fast forward to 2023, and we started hearing more about the IT job market being oversaturated. Tons of people were coming out of boot camps claiming to have 10 years of experience after just a 3-month crash course. Job postings would get 200 applications within hours. Suddenly, just knowing how to code wasn’t enough anymore. Hiring became a mess.&lt;/p&gt;

&lt;p&gt;Now it’s 2024. ChatGPT, Claude, Gemini… Programmers? Who needs them when AI is taking over everything?&lt;/p&gt;

&lt;p&gt;Looking back, I’ve realized that there’s always been something to worry about. It’s human nature to doubt. And yeah, it’s scary to think you might waste time on something that could end up being pointless. But those are just fears and excuses.&lt;/p&gt;

&lt;p&gt;People have always questioned whether web development is still worth it, and you could spend forever doubting yourself. But over the past five years, you could’ve built a solid career. There will always be reasons not to dive into web development, but the web will keep evolving. So the real question is…&lt;/p&gt;

&lt;p&gt;... is it too late to learn web development in 2025? 🤣&lt;/p&gt;

&lt;p&gt;Follow me on Telegram: &lt;a href="https://t.me/mike_in_web" rel="noopener noreferrer"&gt;t.me/mike_in_web&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to debug i18n? 🤔</title>
      <dc:creator>Michael Grechka</dc:creator>
      <pubDate>Thu, 18 Apr 2024 10:00:00 +0000</pubDate>
      <link>https://dev.to/grech_ca/how-to-debug-i18n-118e</link>
      <guid>https://dev.to/grech_ca/how-to-debug-i18n-118e</guid>
      <description>&lt;p&gt;I've worked a lot with i18n in different projects (using i18next, next-intl, etc) and what I always lacked was a playground where I could debug the complex template strings.&lt;/p&gt;

&lt;p&gt;It was really annoying to always check the result by refreshing the page, especially when the project is too heavy (like 🐌 🐌 🐌) to refresh instantly and you have to wait forever for the page to load after adding just a single missing bracket in the template string 😭.&lt;/p&gt;

&lt;p&gt;🎉 Fortunately, I've made the &lt;a href="https://i18n-playground.com" rel="noopener noreferrer"&gt;i18n Playground&lt;/a&gt;, a tool where you can debug template strings with less effort as you can select a quick preset and forget about reading the docs over and over again. Currently, it only support messageformat which is commonly used across different i18n libraries. 💅🏻&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xHkJL54-t6o"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>React types you didn't know</title>
      <dc:creator>Michael Grechka</dc:creator>
      <pubDate>Wed, 08 Sep 2021 20:55:38 +0000</pubDate>
      <link>https://dev.to/grech_ca/react-types-you-didn-t-know-12cp</link>
      <guid>https://dev.to/grech_ca/react-types-you-didn-t-know-12cp</guid>
      <description>&lt;p&gt;After working in several companies, I've noticed that the code is always typed differently and this can lead to some issues with typings in the future.&lt;/p&gt;

&lt;p&gt;I want to show you how to make code better typed the way you probably didn't know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Component type
&lt;/h2&gt;

&lt;p&gt;First of all, we have to figure out what is the best way to define a function component.&lt;/p&gt;

&lt;p&gt;Usually developers do initialise components using default functions so the code would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;SomeComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SomeComponentProps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;JSX&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Such approach has several disadvantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You always need to write the return type&lt;/li&gt;
&lt;li&gt;If your component accepts any children you need to define the &lt;code&gt;children&lt;/code&gt; property in your Props type and set the type union type like &lt;code&gt;null | ReactNode | ReactNode[]&lt;/code&gt; or &lt;code&gt;null | ReactElement&lt;/code&gt;
– Since you need to use one of types above for your children, you have to import them too&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these problems make your code more "boilerplaty" and make your code less readable spending more time than you can.&lt;/p&gt;

&lt;p&gt;The best solution for this is &lt;code&gt;FC&lt;/code&gt; or &lt;code&gt;FunctionComponent&lt;/code&gt; types. &lt;code&gt;FC&lt;/code&gt; is just a shorthand for &lt;code&gt;FunctionComponent&lt;/code&gt; – You can check this &lt;a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/d195fb003a300937e6da60bc3d7e7bff548db519/types/babel-plugin-react-html-attrs/index.d.ts#L554" rel="noopener noreferrer"&gt;here&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;FC&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;FunctionComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see what this &lt;code&gt;FunctionComponent&lt;/code&gt; is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;FunctionComponent&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropsWithChildren&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;ReactElement&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;propTypes&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;WeakValidationMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;contextTypes&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;ValidationMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;defaultProps&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we also need to check the &lt;code&gt;PropsWithChildren&lt;/code&gt; type to make sure what we will pass to the component's props:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;PropsWithChildren&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;P&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;P&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;ReactNode&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's see how FC-typed component looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SomeComponent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;FC&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SomeComponentProps&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Current solution solves such problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We don't need to define children¹ type anymore&lt;/li&gt;
&lt;li&gt;We separate values from types moving generic type to the beginning making the code more readable&lt;/li&gt;
&lt;li&gt;We don't need to write a function return type&lt;/li&gt;
&lt;li&gt;Since we are using arrow function², we can omit curly braces in some cases and return jsx directly&lt;/li&gt;
&lt;li&gt;Using the same component type everywhere we prevent inconsistency of types that can lead to waste of time because of type definition instead of spending it to solve actual problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1 - Keep in mind that it is planned to remove &lt;code&gt;children&lt;/code&gt; as default property from &lt;code&gt;FunctionComponent&lt;/code&gt; in &lt;code&gt;@types/react@^18.0.0&lt;/code&gt;. In the React 18 you should define children property manually and set &lt;code&gt;ReactNode&lt;/code&gt; type to it.&lt;br&gt;
2 – If you are using React Developer Tools you should notice that arrow functions don't have &lt;code&gt;displayName&lt;/code&gt; by default so you should define it manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;SomeComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;displayName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SomeComponent&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Type of regular HTML props / attributes
&lt;/h2&gt;

&lt;p&gt;You've probably had problems with props definition for components that pass most of their props further to the regular html element.&lt;/p&gt;

&lt;p&gt;Previously I've seen solutions like importing &lt;code&gt;HTMLAttributes&lt;/code&gt; from &lt;code&gt;react&lt;/code&gt; module and then passing &lt;code&gt;HTML...Element&lt;/code&gt; type to it as a generic argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;SomeType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;HTMLAttributes&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLInputElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This type is not much reusable because we cannot get props of the custom component and this is where &lt;code&gt;ComponentProps&lt;/code&gt; comes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt; &lt;span class="c1"&gt;// regular HTML input element&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;InputElementProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ComponentProps&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ComponentProps works for both regular elements and the custom ones&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CustomInputProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ComponentProps&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;CustomInput&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS property type
&lt;/h2&gt;

&lt;p&gt;If you use css-in-js solutions, sometimes you want your component to accept certain CSS-properties passed deeper to the component's styles.&lt;/p&gt;

&lt;p&gt;You can just set the property type as a type union: &lt;code&gt;number | string&lt;/code&gt; but it is unspecific and can lead to unpredicted behaviour because of typos when using such properties as &lt;code&gt;position&lt;/code&gt;, &lt;code&gt;flex-direction&lt;/code&gt;, etc.&lt;/p&gt;

&lt;p&gt;The better solution is to use &lt;code&gt;CSSProperties&lt;/code&gt; type exported from &lt;code&gt;react&lt;/code&gt; module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;SomeComponentProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CSSProperties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Such little things may improve the quality of your code and prevent you from having pain with Typescript.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
