<?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: Wenchen (Neo) Li</title>
    <description>The latest articles on DEV Community by Wenchen (Neo) Li (@li).</description>
    <link>https://dev.to/li</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%2F134657%2F9a8c7caa-1d83-40c8-bb76-01e32ee7e76b.png</url>
      <title>DEV Community: Wenchen (Neo) Li</title>
      <link>https://dev.to/li</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/li"/>
    <language>en</language>
    <item>
      <title>(Correctly) Telling git about your SSH key for signing commits</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 26 Aug 2022 21:30:47 +0000</pubDate>
      <link>https://dev.to/li/correctly-telling-git-about-your-ssh-key-for-signing-commits-4c2c</link>
      <guid>https://dev.to/li/correctly-telling-git-about-your-ssh-key-for-signing-commits-4c2c</guid>
      <description>&lt;p&gt;GitHub recently added a feature to support &lt;a href="https://github.blog/changelog/2022-08-23-ssh-commit-verification-now-supported/"&gt;SSH commit verification&lt;/a&gt;, which in my opinion, should be easier than using GPG. (Git has released signing with SSH key since &lt;a href="https://github.blog/2021-11-15-highlights-from-git-2-34/#tidbits"&gt;2.34&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;After generating your SSH key pair (which you can learn about from &lt;a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"&gt;here&lt;/a&gt;, you now need to tell git about it. And the way to do it is through the &lt;code&gt;user.signingkey&lt;/code&gt; git config.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good
&lt;/h2&gt;

&lt;p&gt;However for some reasons, almost all of the tutorials and instructions online are saying you would need to copy and paste the literal public key as the git config value like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// NOT 100% correct example, explanation below
&lt;span class="nv"&gt;$ &lt;/span&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey &lt;span class="s1"&gt;'ssh-ed25519 AAAAC3(...)'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Better
&lt;/h2&gt;

&lt;p&gt;While it seems to work (actually only with non-physical keys), I found that you could also provide your public key file path like this, which might be better in some ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the same time I also found that the "proper" way to do literal public key value is to prefix with &lt;code&gt;key::&lt;/code&gt;, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey &lt;span class="s2"&gt;"key::ssh-ed25519 (...)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I found out from what appears to be the git mailing list archive? &lt;a href="https://lore.kernel.org/git/20220628162342.ootjobbjtxg7b7ay@fs/t/"&gt;https://lore.kernel.org/git/20220628162342.ootjobbjtxg7b7ay@fs/t/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Physical security keys
&lt;/h2&gt;

&lt;p&gt;All the FIDO2 devices (not only the more sophisticated YubiKeys, which can do resident/discoverable keys though) should be able to generate SSH keys since &lt;a href="https://www.openssh.com/txt/release-8.2"&gt;OpenSSH 8.2&lt;/a&gt;. So I wanted to utilize my physical security keys with this, and that's when I got this error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Couldn't load public key sk-ssh-ed25519@openssh.com AAAA(...)
: No such file or directory?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's actually when I had to search and found out for a SSH key pair generated from a physical security key which has &lt;code&gt;sk-ssh&lt;/code&gt; prefixed in public key literal string, or &lt;code&gt;_sk&lt;/code&gt; suffixed in the key file name, a prefix of &lt;code&gt;key::&lt;/code&gt; is required for the literal public key git config value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey &lt;span class="s2"&gt;"key::sk-ssh-ed25519@openssh.com AAAA(...)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  File path is just easier
&lt;/h2&gt;

&lt;p&gt;So in conclusion, using file path for this config is just easier in many ways and would prevent the prefix missing error (&lt;code&gt;No such file or directory?&lt;/code&gt;) from the root of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some lines for copy and paste
&lt;/h2&gt;

&lt;p&gt;Lastly as bonus content, here are some lines for your convenience 😆&lt;/p&gt;

&lt;p&gt;Git config to use SSH for signing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; gpg.format ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Turn on commit and tag signing respectively by default:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; commit.gpgsign &lt;span class="nb"&gt;true
&lt;/span&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; tag.gpgsign &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the &lt;code&gt;user.signingkey&lt;/code&gt; to a pub key generated from a physical security key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey ~/.ssh/id_ed25519_sk.pub

// or &lt;span class="k"&gt;for &lt;/span&gt;an ECDSA key
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.signingkey ~/.ssh/id_ecdsa_sk.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also set it to automatically use the first available key from your ssh-agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; gpg.ssh.defaultKeyCommand &lt;span class="s2"&gt;"ssh-add -L"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note that all of the &lt;code&gt;--global&lt;/code&gt; git config option shown is optional as it's what you likely want, however you can set all of these as local config.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Also note that while I don't know whether there's any difference in other OSs, this was tested on macOS 12.3 only.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Enjoy signing commits with your SSH key! 🎉&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>ssh</category>
      <category>gpg</category>
    </item>
    <item>
      <title>New laptop sticker from Hacktoberfest!</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 10 Jan 2020 19:30:33 +0000</pubDate>
      <link>https://dev.to/li/new-laptop-sticker-from-hacktoberfest-4ml</link>
      <guid>https://dev.to/li/new-laptop-sticker-from-hacktoberfest-4ml</guid>
      <description>&lt;p&gt;So last week I received my t-shirt and stickers from Hacktoberfest last year. I am a minimalist when it comes to laptop stickers; I have had no stickers for a very long time, and then I had just one for a very long time.&lt;/p&gt;

&lt;p&gt;So when I got the stickers, at first I thought I wouldn't want any more stickers on my laptop. But then after carefully thinking about it, I decided to put the sloth on and be like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KGmdju0G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/swcmvj2gnze5zvrmjflo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KGmdju0G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/swcmvj2gnze5zvrmjflo.jpg" alt='Laptop with two stickers on: one is the dev.to sloth mascot and the other one being the "My website is faster than yours" from Gatsby'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So it would be like: my website is faster than yous, (then pointing to the sloth) and this is &lt;em&gt;your&lt;/em&gt; website. 😆&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>gatsby</category>
      <category>github</category>
      <category>jokes</category>
    </item>
    <item>
      <title>How to requestPermission for devicemotion and deviceorientation events in iOS 13+</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 13 Sep 2019 00:03:48 +0000</pubDate>
      <link>https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2</link>
      <guid>https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Since iOS 12.2, Apple decided that for &lt;a href="https://www.macrumors.com/2019/02/04/ios-12-2-safari-motion-orientation-access-toggle/" rel="noopener noreferrer"&gt;privacy reasons&lt;/a&gt;, the in-browser access to the device motion and orientation events is off by default. And now maybe they realized this might be a mistake, so in iOS 13 they &lt;a href="https://developer.apple.com/documentation/safari_release_notes/safari_13_release_notes#3314664." rel="noopener noreferrer"&gt;changed&lt;/a&gt; the permission request behavior similar to how the camera permission is requested.&lt;/p&gt;

&lt;p&gt;So now when we try to &lt;code&gt;addEventListener&lt;/code&gt; to &lt;code&gt;devicemotion&lt;/code&gt; or &lt;code&gt;deviceorientation&lt;/code&gt;, we would see this warning in the console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxd3rs4z30dmaqrgztkj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxd3rs4z30dmaqrgztkj0.png" alt="Console warnings: No device motion or orientation events will be fired until permission has been requested and granted."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To request permission, we would just need to call a method on the &lt;code&gt;DeviceMotionEvent&lt;/code&gt; or &lt;code&gt;DeviceOrientationEvent&lt;/code&gt;: &lt;code&gt;requestPermission&lt;/code&gt; 😂 It would return a promise that always resolve to a &lt;code&gt;PermissionState&lt;/code&gt; which could be &lt;code&gt;granted&lt;/code&gt; or &lt;code&gt;denied&lt;/code&gt; (so basically &lt;code&gt;Promise&amp;lt;'granted'|'denied'&amp;gt;&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  One more thing
&lt;/h2&gt;

&lt;p&gt;One more thing to keep in mind is that &lt;code&gt;requestPermission&lt;/code&gt; could only be called on a user gesture (e.g. click). This is reasonable UX too as we would want to tell users why we are asking for such permissions and let them confirm before prompting them so that they see it coming.&lt;/p&gt;

&lt;p&gt;Otherwise you would get this error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Faf0b5s5t110v4e618t0n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Faf0b5s5t110v4e618t0n.png" alt="Console error: NotAllowedError: Requesting device orientation or motion access requires a user gesture to prompt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The code to copy
&lt;/h2&gt;

&lt;p&gt;For &lt;code&gt;devicemotion&lt;/code&gt; events:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// feature detect&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;DeviceMotionEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requestPermission&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;function&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;span class="nx"&gt;DeviceMotionEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;permissionState&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;permissionState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;granted&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;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;devicemotion&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;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="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// handle regular non iOS 13+ devices&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;and for &lt;code&gt;deviceorientation&lt;/code&gt; events:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// feature detect&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;DeviceOrientationEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requestPermission&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;function&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;span class="nx"&gt;DeviceOrientationEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;permissionState&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;permissionState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;granted&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;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;deviceorientation&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;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="p"&gt;})&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// handle regular non iOS 13+ devices&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;That's it. Thank you for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Pursue a CS Degree or not? As a Front-End Developer</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Sat, 30 Mar 2019 14:30:00 +0000</pubDate>
      <link>https://dev.to/li/pursue-a-cs-degree-or-not-as-a-front-end-developer-3oim</link>
      <guid>https://dev.to/li/pursue-a-cs-degree-or-not-as-a-front-end-developer-3oim</guid>
      <description>&lt;p&gt;I've been considering this for a while, that if I should go pursue a undergrad degree in computer science after I had self-taught myself front-end development and have been working for time for 2.5 years.&lt;/p&gt;

&lt;p&gt;I guess it also depends on my career goals: if I want to keep doing pixel perfect performant web stuff, and then become a manager some day in the future, then I probably don't need a degree. But if I want to explore more in the programming world, or even science part of the computer world with other career options, then I probably would want to go back to school for it...&lt;/p&gt;

&lt;p&gt;What's your experience? What do you think? 🤔&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>computerscience</category>
      <category>career</category>
    </item>
    <item>
      <title>Today I Finished MITx 600 Part 1!</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 22 Mar 2019 01:40:47 +0000</pubDate>
      <link>https://dev.to/li/today-i-finished-mitx-600-part-1-3b1d</link>
      <guid>https://dev.to/li/today-i-finished-mitx-600-part-1-3b1d</guid>
      <description>&lt;p&gt;Tonight I finished the &lt;a href="https://www.edx.org/course/introduction-to-computer-science-and-programming-using-python-0" rel="noopener noreferrer"&gt;MITx: Introduction to Computer Science and Programming Using Python&lt;/a&gt; right on deadline! (well actually a little passed the deadline) 🎉&lt;/p&gt;

&lt;p&gt;As a front end developer who doesn't have a degree in computer science, I always desire to learn more about "the real stuff" of computer science. Last year I took &lt;a href="https://www.edx.org/course/cs50s-introduction-to-computer-science" rel="noopener noreferrer"&gt;HarvardX CS50x&lt;/a&gt; (only the C part though) and felt really great about it. The content is not only useful but also fascinating.&lt;/p&gt;

&lt;p&gt;So this year I decided to try this MIT one out again; I said again because I actually tried it when I was in school but couldn't finish it (twice!). But this time despite the fact that I'm working now and have less time to work on this, I am still able to finish it! (Big thanks to my girlfriend &lt;a class="mentioned-user" href="https://dev.to/rachel"&gt;@rachel&lt;/a&gt; for supporting and producing me! 😄)&lt;/p&gt;

&lt;p&gt;To continue this momentum of success, next week I'll start on the second part of the MITx 600 course: &lt;a href="https://www.edx.org/course/introduction-to-computational-thinking-and-data-science-2" rel="noopener noreferrer"&gt;Introduction to Computational Thinking and Data Science&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the future I'm hoping to also get some more math in my brain. I've been looking at the courses from &lt;a href="https://github.com/ossu/computer-science#core-math" rel="noopener noreferrer"&gt;here&lt;/a&gt;. And by the way, this is a great resource to gradually learn computer science with a clear plan! I really appreciate the community that put this together:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ossu" rel="noopener noreferrer"&gt;
        ossu
      &lt;/a&gt; / &lt;a href="https://github.com/ossu/computer-science" rel="noopener noreferrer"&gt;
        computer-science
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🎓 Path to a free self-taught education in Computer Science!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/84b5313fc6ba24ed82df5127838550744af8578edf9ef68f713a2c3639397423/687474703a2f2f692e696d6775722e636f6d2f6b5959435874432e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/84b5313fc6ba24ed82df5127838550744af8578edf9ef68f713a2c3639397423/687474703a2f2f692e696d6775722e636f6d2f6b5959435874432e706e67" alt="Open Source Society logo"&gt;&lt;/a&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Open Source Society University&lt;/h3&gt;
&lt;/div&gt;
&lt;p&gt;
  Path to a free self-taught education in Computer Science
&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://github.com/sindresorhus/awesome" rel="noopener noreferrer"&gt;
    &lt;img alt="Awesome" src="https://camo.githubusercontent.com/8693bde04030b1670d5097703441005eba34240c32d1df1eb82a5f0d6716518e/68747470733a2f2f63646e2e7261776769742e636f6d2f73696e647265736f726875732f617765736f6d652f643733303566333864323966656437386661383536353265336136336531353464643865383832392f6d656469612f62616467652e737667"&gt;&lt;/a&gt;
  &lt;a href="https://github.com/ossu/computer-science" rel="noopener noreferrer"&gt;
    &lt;img alt="Open Source Society University - Computer Science" src="https://camo.githubusercontent.com/8f259081bbe6f0755e9e882d812f76315a5749b483789d3d8056ff1a33ccd273/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f5353552d636f6d70757465722d2d736369656e63652d626c75652e737667"&gt;&lt;/a&gt;
&lt;/p&gt;


&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Contents&lt;/h1&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/ossu/computer-science#summary" rel="noopener noreferrer"&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ossu/computer-science#community" rel="noopener noreferrer"&gt;Community&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ossu/computer-science#curriculum" rel="noopener noreferrer"&gt;Curriculum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ossu/computer-science#code-of-conduct" rel="noopener noreferrer"&gt;Code of conduct&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ossu/computer-science#team" rel="noopener noreferrer"&gt;Team&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Summary&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;The OSSU curriculum is a &lt;strong&gt;complete education in computer science&lt;/strong&gt; using online materials.
It's not merely for career training or professional development.
It's for those who want a proper, &lt;em&gt;well-rounded&lt;/em&gt; grounding in concepts fundamental to all computing disciplines,
and for those who have the discipline, will, and (most importantly!) good habits to obtain this education largely on their own,
but with support from a worldwide community of fellow learners.&lt;/p&gt;
&lt;p&gt;It is designed according to the degree requirements of undergraduate computer science majors, minus general education (non-CS) requirements
as it is assumed most of the people following this curriculum are already educated outside the field of CS.
The courses themselves are among the very best in the world, often coming from Harvard, Princeton, MIT, etc.,
but specifically chosen to…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/ossu/computer-science" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Cool, that's all I wanted to share, and I hope we could all keep learning and having fun!&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>career</category>
      <category>python</category>
      <category>mooc</category>
    </item>
    <item>
      <title>React SSR with PHP and WordPress</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Thu, 14 Mar 2019 19:32:59 +0000</pubDate>
      <link>https://dev.to/li/react-ssr-with-php-and-wordpress-32j1</link>
      <guid>https://dev.to/li/react-ssr-with-php-and-wordpress-32j1</guid>
      <description>&lt;p&gt;I am looking for a solution that use React for the font-end and WordPress for the backend with the following requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No static rendering at build time:

&lt;ul&gt;
&lt;li&gt;Was actually thinking Gatsby or React Static at first, but it requires not to re-build every time the content updates&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;No node.js middleware:

&lt;ul&gt;
&lt;li&gt;Cannot add a middleware to call the WordPress api and then render React&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;No classic SPA:

&lt;ul&gt;
&lt;li&gt;For SEO and performance considerations, we want not just a blank page coming back from the response&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A potential solution we're looking at is to use Gatsby or React Static to build and then use PHP to update the generated HTML and JSON with the latest content, which isn't really an ideal solution in my opinion; so reaching out to see if there's any other solutions.&lt;/p&gt;

&lt;p&gt;Thanks a lot!&lt;/p&gt;

</description>
      <category>help</category>
      <category>discuss</category>
      <category>requestforpost</category>
      <category>react</category>
    </item>
    <item>
      <title>Microsoft open-sources its Windows calculator on GitHub</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 08 Mar 2019 16:45:53 +0000</pubDate>
      <link>https://dev.to/li/microsoft-open-sources-its-windows-calculator-on-github-1igl</link>
      <guid>https://dev.to/li/microsoft-open-sources-its-windows-calculator-on-github-1igl</guid>
      <description>&lt;p&gt;I believe no one has posted this after a few days of them making it open source.&lt;/p&gt;

&lt;p&gt;Microsoft has been really trying to embrace the open source community! And we are really happy to see that! 😆&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/microsoft" rel="noopener noreferrer"&gt;
        microsoft
      &lt;/a&gt; / &lt;a href="https://github.com/microsoft/calculator" rel="noopener noreferrer"&gt;
        calculator
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Windows Calculator: A simple yet powerful calculator that ships with Windows
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Calculator&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;The Windows Calculator app is a modern Windows app written in C++ and C# that ships pre-installed with Windows
The app provides standard, scientific, and programmer calculator functionality, as well as a set of converters between various units of measurement and currencies.&lt;/p&gt;
&lt;p&gt;Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the &lt;a href="https://www.microsoft.com/store/apps/9WZDNCRFHVN5" rel="nofollow noopener noreferrer"&gt;Microsoft Store&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/microsoft/calculator/actions/workflows/action-ci.yml" rel="noopener noreferrer"&gt;&lt;img src="https://github.com/microsoft/calculator/actions/workflows/action-ci.yml/badge.svg" alt="Continuous Integration"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/microsoft/calculatordocs/Images/CalculatorScreenshot.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fcalculatordocs%2FImages%2FCalculatorScreenshot.png" alt="Calculator Screenshot" width="450px"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Standard Calculator functionality which offers basic operations and evaluates commands immediately as they are entered.&lt;/li&gt;
&lt;li&gt;Scientific Calculator functionality which offers expanded operations and evaluates commands using order of operations.&lt;/li&gt;
&lt;li&gt;Programmer Calculator functionality which offers common mathematical operations for developers including conversion between common bases.&lt;/li&gt;
&lt;li&gt;Date Calculation functionality which offers the difference between two dates, as well as the ability to add/subtract years, months and/or days to/from a given input date.&lt;/li&gt;
&lt;li&gt;Calculation history and memory capabilities.&lt;/li&gt;
&lt;li&gt;Conversion between many units of measurement.&lt;/li&gt;
&lt;li&gt;Currency conversion based…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/microsoft/calculator" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;🎉&lt;/p&gt;

</description>
      <category>githunt</category>
      <category>cpp</category>
      <category>opensource</category>
      <category>github</category>
    </item>
    <item>
      <title>CSS Animation: Growing SVG Arrow</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Thu, 28 Feb 2019 17:00:01 +0000</pubDate>
      <link>https://dev.to/li/css-animation-growing-svg-arrow-4h5c</link>
      <guid>https://dev.to/li/css-animation-growing-svg-arrow-4h5c</guid>
      <description>&lt;p&gt;I have been doing CSS animations with SVG arrows, I thought they're pretty unique but aren't sure if other people think the same. So I'm wondering if there are people who find these interesting and want to know (if haven't already) how to make cute and unique animations like these:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr4b7s44atqo2a7a347x.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr4b7s44atqo2a7a347x.gif" alt="Growing arrow animation 1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56hta169r4tstljqppc2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F56hta169r4tstljqppc2.gif" alt="Growing arrow animation 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please leave a comment below to let me know what do you think! (interested, not really interested or already know how and it's too easy) ❤️&lt;/p&gt;

</description>
      <category>css</category>
      <category>svg</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Selecting elements in children components within CSS modules</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Thu, 21 Feb 2019 17:00:02 +0000</pubDate>
      <link>https://dev.to/li/selecting-elements-in-children-components-within-css-modules-4ll2</link>
      <guid>https://dev.to/li/selecting-elements-in-children-components-within-css-modules-4ll2</guid>
      <description>&lt;p&gt;CSS modules are great, they encapsulate component styles to themselves: so that we could start using &lt;code&gt;.container&lt;/code&gt; for everything in everywhere again 😆&lt;/p&gt;

&lt;p&gt;Not too long ago &lt;code&gt;create-react-app&lt;/code&gt; released version 2 with the feature of using CSS modules. I'm sure once people upgrade to &lt;code&gt;react-scripts@2&lt;/code&gt;, they would immediately opt-in with excitement and start using CSS modules without a doubt: it makes CSS modular like everything else!&lt;/p&gt;

&lt;h2&gt;
  
  
  Inevitable problem
&lt;/h2&gt;

&lt;p&gt;But sooner or later, you would realize there is one thing we cannot easily do anymore in CSS modules – a rather important (if not fundamental) thing in CSS: selecting and overwriting the styles of the (deep nested) child component that’s in a different module from the parent.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Angular and Vue solves the problem
&lt;/h2&gt;

&lt;p&gt;Before we come back to react, let’s take a look at how Angular approaches the problem. In Angular, style encapsulation is actually done in a different way with emulated shadow DOM. The actual implementation is through &lt;a href="https://angular.io/guide/component-styles#inspecting-generated-css"&gt;adding extra generated attributes&lt;/a&gt; to the DOM elements (rather than changing the class names, which will be mentioned below).&lt;/p&gt;

&lt;p&gt;The way to target the child components is simple: you would just need to use &lt;a href="https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep"&gt;&lt;code&gt;::ng-deep&lt;/code&gt; (or &lt;code&gt;/deep/&lt;/code&gt;/&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;)&lt;/a&gt; before the children selectors. And it would generate the styles for that element without any attribute attached, thus achieving the goal to target any nested child elements and get around the view encapsulation.&lt;/p&gt;

&lt;p&gt;With Vue, I haven’t work with it that much, but I saw &lt;a href="https://vue-loader.vuejs.org/guide/scoped-css.html"&gt;this&lt;/a&gt; and assumed it is pretty similar to Angular in terms of implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we could do it in React with CRA
&lt;/h2&gt;

&lt;p&gt;But in CSS modules, the actual implementation is to hash and rename the class names to make sure they are unique.&lt;/p&gt;

&lt;p&gt;That made my first trial to do things in a way that’s similar to Angular failed. My first intuitive way to do it is to use the &lt;code&gt;: global&lt;/code&gt; keyword to un-encapsulate (or de-encapsulate) the child selectors, but that didn't work as the children's selectors are hashed and renamed, which can't be easily targeted in this way.&lt;/p&gt;

&lt;p&gt;Then I talked to &lt;a class="mentioned-user" href="https://dev.to/alemesa"&gt;@alemesa&lt;/a&gt; and found out &lt;a class="mentioned-user" href="https://dev.to/donghyukjacobjang"&gt;@donghyukjacobjang&lt;/a&gt; and he are doing each component with an un-scoped normal string class name which has the sole purpose of being targeted from outside of the CSS module. This way has been working for them quite well, but in my opinion, this way is more like a convention that people have to follow; and it somewhat defeats the purpose and benefits of using CSS modules.&lt;/p&gt;

&lt;p&gt;After doing some searches, I still couldn’t find anything that’s quite similar to how Angular and Vue do it. But I did find an interesting solution &lt;a href="http://engineering.liefery.com/2018/06/27/overriding-styles-with-CSS-modules.html"&gt;here&lt;/a&gt; that could satisfy me and my needs. It suggests that we could define a child and its styles in a parent module first, and then import the child class name and pass that down to the child as one of the props in JSX. This solution, in my opinion, is still kind of a way by convention as the children would need to know to expect and use the class names from the props. But it’s the best solution I could find/think of at the moment, and it also provides more predictability and stability compared to the Angular/Vue way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Although at the moment if you ask me, I would still prefer the shadow DOM implementation and emulation with HTML element attributes like the way in Angular, CSS modules are great too! It’s very easy to opt-in (thanks to CRA too!), and also you could migrate to it gradually and starting enjoying its benefit today.&lt;/p&gt;

&lt;p&gt;All I have to say is that with all the benefits, it also comes with some minor issues that you need to consider before jumping into it, and the problem we discussed here is one of them. Moreover, I’d like to also point out a few other things I noticed for your consideration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is recommended that you use &lt;code&gt;camelCase&lt;/code&gt; for the class names. (You could use &lt;code&gt;kabab-case&lt;/code&gt;, but you would not want to.)&lt;/li&gt;
&lt;li&gt;The generated class names (with the CRA setup) are not uglified and usually very long (long enough to increase the bundle size).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please leave a comment to share your opinions and solutions to this problem, cheers!&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>The pursuit of difference between CSS grid and flexbox</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Fri, 15 Feb 2019 16:00:01 +0000</pubDate>
      <link>https://dev.to/li/the-pursuit-of-difference-between-css-grid-and-flexbox-277n</link>
      <guid>https://dev.to/li/the-pursuit-of-difference-between-css-grid-and-flexbox-277n</guid>
      <description>&lt;p&gt;Yesterday I came across the discussion of this question:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--2WRKSjk_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/883049860332609537/IsUISvAq_normal.jpg" alt="Chris Coyier profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Chris Coyier
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="mentioned-user" href="https://dev.to/chriscoyier"&gt;@chriscoyier&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      For y'all that have an understand of both CSS grid and flexbox, what's your favorite way of explaining the difference?
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      15:53 PM - 25 Jan 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1088827201468813312" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1088827201468813312" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1088827201468813312" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;And it seemed like the best answer is this from Rachel:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--TX7GGaP_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/781380559947915265/wrjtv_jp_normal.jpg" alt="Rachel Andrew profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Rachel Andrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @rachelandrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/chriscoyier"&gt;@chriscoyier&lt;/a&gt; Flexbox is for one dimensional layout. A row OR a column. Grid is for two dimensional layout. Rows AND columns.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      15:55 PM - 25 Jan 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1088827732874747910" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1088827732874747910" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1088827732874747910" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;It's a very straight forward answer and I was like "oh, ok." and moved on.&lt;/p&gt;




&lt;h1&gt;
  
  
  🤔
&lt;/h1&gt;

&lt;p&gt;But last night when I was in bed, I got started thinking about this again: I just didn't think this is it.&lt;/p&gt;

&lt;p&gt;And when I was thinking it more, I realized it's also about the organization and relationship between the parent and the children: &lt;strong&gt;in flexbox, the children dictate how the layout is organized as well as its own space proportion; meanwhile in grid, the parent decides how things are aligned and what proportion of space each child should take.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After realizing that, I went to sleep peacefully. 🌝&lt;/p&gt;




&lt;p&gt;And this morning, I can't wait to share my discovery with the community.&lt;br&gt;
When I was looking for the tweets above to embed, I saw the other branch of the thread, which has the same conclusion as I do! 🤓&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--2WRKSjk_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/883049860332609537/IsUISvAq_normal.jpg" alt="Chris Coyier profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Chris Coyier
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        &lt;a class="mentioned-user" href="https://dev.to/chriscoyier"&gt;@chriscoyier&lt;/a&gt;
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      I'm not the world's biggest fan of the 1D vs 2D differentiation of grid vs flexbox, only because I find most of my day-to-day usage of grid is 1D and it's great for that. It is a strong distinction though that 2D layout is _possible_ with grid though in ways it is not in flexbox.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      16:11 PM - 25 Jan 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1088831796819648512" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1088831796819648512" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1088831796819648512" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;br&gt;
&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--TX7GGaP_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/781380559947915265/wrjtv_jp_normal.jpg" alt="Rachel Andrew profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Rachel Andrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @rachelandrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/chriscoyier"&gt;@chriscoyier&lt;/a&gt; There is a more subtle difference in whether you want to specify down from the parent, or up from the children. I often explain flexbox as being best when you have a bunch of stuff of different sizes and just want a reasonable in proportion layout from them.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      16:20 PM - 25 Jan 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1088833882592555011" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1088833882592555011" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1088833882592555011" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;So the conclusion is that the difference between flexbox and grid is &lt;em&gt;not just&lt;/em&gt; one dimensional or two, but also &lt;strong&gt;whether the parent or the children should specify the size and proportion of the content.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;Last but not least, in case you're wondering which one to choose and use, here's a way to help you decide:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--TX7GGaP_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/781380559947915265/wrjtv_jp_normal.jpg" alt="Rachel Andrew profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Rachel Andrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @rachelandrew
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ir1kO05j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/chriscoyier"&gt;@chriscoyier&lt;/a&gt; If you start constraining all your flex items with a width, then more often than not it will be easier to use grid.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      16:21 PM - 25 Jan 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1088834299128958982" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFnoeFxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-reply-action-238fe0a37991706a6880ed13941c3efd6b371e4aefe288fe8e0db85250708bc4.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1088834299128958982" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k6dcrOn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-retweet-action-632c83532a4e7de573c5c08dbb090ee18b348b13e2793175fea914827bc42046.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/like?tweet_id=1088834299128958982" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SRQc9lOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/twitter-like-action-1ea89f4b87c7d37465b0eb78d51fcb7fe6c03a089805d7ea014ba71365be5171.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;Cheers and ciao! 😆&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>React Hooks Released! (Finally 🎉)</title>
      <dc:creator>Wenchen (Neo) Li</dc:creator>
      <pubDate>Wed, 06 Feb 2019 16:28:16 +0000</pubDate>
      <link>https://dev.to/li/react-hooks-released-finally--1mn3</link>
      <guid>https://dev.to/li/react-hooks-released-finally--1mn3</guid>
      <description>&lt;p&gt;After a lot of waiting...&lt;br&gt;
&lt;iframe class="tweet-embed" id="tweet-1092920897143521287-460" src="https://platform.twitter.com/embed/Tweet.html?id=1092920897143521287"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1092920897143521287-460');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1092920897143521287&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;We finally have React with Hooks to use! &lt;a href="https://reactjs.org/blog/2019/02/06/react-v16.8.0.html" rel="noopener noreferrer"&gt;https://reactjs.org/blog/2019/02/06/react-v16.8.0.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I also created a custom hook to use scroll position last month: &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/neo" rel="noopener noreferrer"&gt;
        neo
      &lt;/a&gt; / &lt;a href="https://github.com/neo/react-use-scroll-position" rel="noopener noreferrer"&gt;
        react-use-scroll-position
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A react hook to use scroll position
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;react-use-scroll-position&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://www.npmjs.com/package/react-use-scroll-position" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/8bccb9c84955334528628e72a892c42cc6db03d11d1276e462d93c73a439e7cd/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f72656163742d7573652d7363726f6c6c2d706f736974696f6e2e737667" alt="npm package"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/90e2e9f0d18b5db524d8f0d1f0554aba376de0ab6f2a836c106b21f92e78461c/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f74797065732f72656163742d7573652d7363726f6c6c2d706f736974696f6e2e737667"&gt;&lt;img src="https://camo.githubusercontent.com/90e2e9f0d18b5db524d8f0d1f0554aba376de0ab6f2a836c106b21f92e78461c/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f74797065732f72656163742d7573652d7363726f6c6c2d706f736974696f6e2e737667" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A &lt;a href="https://reactjs.org/docs/hooks-intro.html" rel="nofollow noopener noreferrer"&gt;react hook&lt;/a&gt; to use scroll position.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Usage&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;In a React functional component:&lt;/h3&gt;
&lt;/div&gt;
&lt;div class="highlight highlight-source-tsx notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-smi"&gt;React&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'react'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-c"&gt;// Usually you would just need to import one of the following&lt;/span&gt;
&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-s1"&gt;useScrollPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;useScrollXPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;useScrollYPosition&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'react-use-scroll-position'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-k"&gt;function&lt;/span&gt; &lt;span class="pl-smi"&gt;Example&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; x&lt;span class="pl-kos"&gt;,&lt;/span&gt; y &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;useScrollPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;scrollX&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;useScrollXPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;scrollY&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;useScrollYPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-kos"&gt;(&lt;/span&gt;
    &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-ent"&gt;p&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="pl-kos"&gt;{&lt;/span&gt;&lt;span class="pl-s1"&gt;x&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt; should equal to &lt;span class="pl-kos"&gt;{&lt;/span&gt;&lt;span class="pl-s1"&gt;scrollX&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;.
      &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-c1"&gt;/&lt;/span&gt;&lt;span class="pl-ent"&gt;p&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-ent"&gt;p&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="pl-kos"&gt;{&lt;/span&gt;&lt;span class="pl-s1"&gt;y&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt; should equal to &lt;span class="pl-kos"&gt;{&lt;/span&gt;&lt;span class="pl-s1"&gt;scrollY&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;.
      &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-c1"&gt;/&lt;/span&gt;&lt;span class="pl-ent"&gt;p&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="pl-c1"&gt;&amp;lt;&lt;/span&gt;&lt;span class="pl-c1"&gt;/&lt;/span&gt;&lt;span class="pl-c1"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;In a custom React hook&lt;/h3&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-tsx notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-s1"&gt;useScrollPosition&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'react-use-scroll-position'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-k"&gt;function&lt;/span&gt; &lt;span class="pl-en"&gt;useYourImagination&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; x&lt;span class="pl-kos"&gt;,&lt;/span&gt; y &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;useScrollPosition&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-en"&gt;getSomethingAwesomeWith&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;x&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;y&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/neo/react-use-scroll-position" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
