<?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[Workshop.me - Medium]]></title>
        <description><![CDATA[Stories from our instructors and friends. - Medium]]></description>
        <link>https://medium.com/workshop-me?source=rss----ff8e00d4c498---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Workshop.me - Medium</title>
            <link>https://medium.com/workshop-me?source=rss----ff8e00d4c498---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:46:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/workshop-me" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Traced SVG Images For Excellent UX with Gatsby.js]]></title>
            <link>https://medium.com/workshop-me/traced-svg-images-for-excellent-ux-d75a6bb4caed?source=rss----ff8e00d4c498---4</link>
            <guid isPermaLink="false">https://medium.com/p/d75a6bb4caed</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[gatsbyjs]]></category>
            <dc:creator><![CDATA[Ryan Florence]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 22:21:14 GMT</pubDate>
            <atom:updated>2018-03-28T22:29:45.808Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*2t8cHCM5N8wIHA_fKrGKKg.jpeg" /></figure><p>I want to show you a sweet image technique to improve the user experience on your site that’s probably more trouble than its worth without the right tools.</p><p>1. Create a traced SVG version of your image<br>2. Render that first with HTML<br>3. Apply a little CSS to help sell it<br>4. When the image loads, replace the SVG with the high res image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*NMPXi8dIs9D1bgOq_Ugj-w.gif" /></figure><p><a href="https://www.gatsbyjs.org/">Gatsby</a> makes this <em>really</em> easy. Feel free to just read this article, or pop open your command prompt and follow along.</p><p>First, install gatsby and create your site:</p><pre>yarn global add gatsby-cli<br>gatsby new my-site<br>cd my-site<br>yarn start</pre><p>Now visit <a href="http://localhost:8000/">localhost:8000</a>, you should see the Gatsby starter site.</p><p>Next add the dependencies we need:</p><pre># ctrl+c to stop the server</pre><pre>yarn add gatsby-plugin-sharp \<br>  gatsby-source-filesystem \<br>  gatsby-transformer-sharp</pre><p>Gatsby Source Filesystem lets us query the files in our project with GraphQL, Gatsby Transformer Sharp lets us transform those files in our queries with <a href="https://github.com/lovell/sharp">Sharp Image Processing</a>, and Gatsby Plugin Sharp is just a dependency of Gatsby Transformer Sharp.</p><p>Wait, what do you mean query the file system with GraphQL?</p><p>Check it out, go visit <a href="http://localhost:8000/__graphql">http://localhost:8000/__graphql</a> and plug this query in:</p><pre>{<br>  allFile {<br>    edges {<br>      node {<br>        id<br>      }<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jmeGpq2IlPTIYbKlOqMTg.png" /></figure><p>Try this one:</p><pre>{<br>  allFile {<br>    edges {<br>      node {<br>        id<br>        size<br>        extension<br>      }<br>    }<br>  }<br>}</pre><p>Pretty cool! Now if you put <a href="https://gatsby-article.now.sh/newyork.jpg">this image</a> of New York at src/newyork.jpg, you can now use a query to transform the image to its JPG source <em>and</em> a traced SVG:</p><pre>{<br>  nyc: imageSharp(id: {regex: &quot;/newyork.jpg/&quot;}) {<br>    sizes(<br>      quality: 100,<br>      traceSVG: {<br>        color: &quot;rgb(56, 47, 92)&quot;,<br>        threshold: 75<br>      },<br>      toFormat: JPG<br>    ) {<br>      tracedSVG<br>      src<br>    }<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqDda05NwuK7Ag6stZ42bA.png" /></figure><p>Check out that data URI for the traced SVG! Now we can use that query on our index page by adding this to src/pages/index.js:</p><pre>export const query = graphql`<br>  query IndexQuery {<br>    nyc: imageSharp(id: { regex: &quot;/newyork.jpg/&quot; }) {<br>      sizes(<br>        quality: 100<br>        traceSVG: { color: &quot;rgb(56, 47, 92)&quot;, threshold: 75 }<br>        toFormat: JPG<br>      ) {<br>        tracedSVG<br>        src<br>      }<br>    }<br>  }<br>`</pre><p>But for completeness, here’s a Gist of the entire src/pages/index.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/debff2e2c700a238663c09e338a59d74/href">https://medium.com/media/debff2e2c700a238663c09e338a59d74/href</a></iframe><p>Now for some fun, build the site and visit it in Chrome with network throttling on to see what its like for visitors with slow connections.</p><pre>yarn global add http-server<br>yarn build<br>cd public<br>http-server</pre><p>Open up <a href="http://localhost:8080/">localhost:8080</a>, then open the chrome dev tools and turn on network throttling under the Network tab. Now reload and see the experience for somebody on a slow network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*G8buDP9zvAX6_98H61xDaw.gif" /></figure><p>Or you can just visit the <a href="https://gatsby-article.now.sh/">demo site right here</a>.</p><p>Gatsby makes hard stuff easy, and I love it. If you build websites, you should give <a href="https://www.gatsbyjs.org/">Gatsby</a> a shot.</p><p>You should also sign up for one of the Gatsby workshops that Kyle Mathews, the creator of Gatsby, is giving in San Francisco and New York, use these links for 10% off :)</p><p><a href="https://workshop.me/2018-04-gatsby?a=medium">April 12th-13th, 2018 in San Francisco</a></p><p><a href="https://workshop.me/2018-05-gatsby?a=medium">May 3rd-4th, 2018 in New York City</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d75a6bb4caed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/workshop-me/traced-svg-images-for-excellent-ux-d75a6bb4caed">Traced SVG Images For Excellent UX with Gatsby.js</a> was originally published in <a href="https://medium.com/workshop-me">Workshop.me</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Render Props, React.createContext … But How?]]></title>
            <link>https://medium.com/workshop-me/render-props-react-createcontext-but-how-9c8e457a90e3?source=rss----ff8e00d4c498---4</link>
            <guid isPermaLink="false">https://medium.com/p/9c8e457a90e3</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ryan Florence]]></dc:creator>
            <pubDate>Mon, 05 Mar 2018 18:10:06 GMT</pubDate>
            <atom:updated>2018-10-05T19:07:29.603Z</atom:updated>
            <content:encoded><![CDATA[<h3>Render Props, React.createContext, Event Handlers, Lifecycles … But How?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAU7u4ZDh56hCdM22pGGpw.jpeg" /></figure><p>React is introducing a <a href="https://github.com/jamiebuilds/create-react-context">new context API</a> that uses <a href="https://courses.totalreact.com/courses/advanced-react-free/lectures/3897316">render props</a>. I see a lot of questions come up at workshops, meetups, and on twitter about how to use render props outside of render, like in event handlers and lifecycle hooks.</p><p>A year and a half ago, when I was working on React Router v4, I was particularly interested in solving the “deep updates” problem once and for all. I created a library called “react-context-emission” (it later became “react-broadcast”) with a conceptually identical API to the new React Context API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0eefea6fe46905d486f19315677d015f/href">https://medium.com/media/0eefea6fe46905d486f19315677d015f/href</a></iframe><p>After using this pattern a bit, I really liked connecting values through context with components and render props, but I struggled to access context values <em>outside</em> of rendering. I was used to getting it from this.context anywhere in my component. It’s one of the reasons we went back to using the current (old?) contextTypes API directly in React Router.</p><p>This problem is not so hard to deal with though. It took me a while to figure it out for myself. But, once you see it, it’s obvious. Check it out!</p><h3>Accessing Values in Event Handlers</h3><p>Just, uh… pass the value into the handler:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c499b5a9390e6ea6e7f76c018aac9f8/href">https://medium.com/media/6c499b5a9390e6ea6e7f76c018aac9f8/href</a></iframe><h3>Accessing Values in Lifecycle Hooks</h3><p>The previous pattern doesn’t work for lifecycle hooks since we don’t call the hooks, React does. Here are three patterns I’ve used, so pick your favorite (mine is the last!).</p><h4>Wrap It</h4><p>You can get access to the data by creating two components, a container that consumes the context and a second that receives the context as a prop.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08394ec05915ff06cd2da610f30df952/href">https://medium.com/media/08394ec05915ff06cd2da610f30df952/href</a></iframe><h4>Make a Higher Order Component</h4><p>Maybe you’re already used to decorating components with higher order components. It’s pretty quick to turn a render prop into a higher order component. I don’t like this one very much cause there’s lots of code shuffling and multiple concepts to make it happen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff2b43b2ae0dfb59cfa952bf2f5fc1e9/href">https://medium.com/media/ff2b43b2ae0dfb59cfa952bf2f5fc1e9/href</a></iframe><h4>The Component Component: My New Love</h4><p>One day I made a component that simply took a function as a prop and called the function in componentDidUpdate. I’d already been making props named render and now I had one called didUpdate. I realized that I could turn every method of a component class into a component prop, and then <a href="https://reactions.github.io/component/">@reactions/component</a> was born!</p><p>It’s really handy to compose render props into lifecycle hooks without all the code shuffling.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a95514e827bbdf754dcde6cf76d0755a/href">https://medium.com/media/a95514e827bbdf754dcde6cf76d0755a/href</a></iframe><p>It’s common to diff the props in componentDidUpdate, that works out just fine, too:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79ed068e2187fdf65c9406d0220b604d/href">https://medium.com/media/79ed068e2187fdf65c9406d0220b604d/href</a></iframe><p>That’s my favorite way to deal with it. The code can change and be moved around without friction because it doesn’t introduce new concepts, all composition happens with components. If you no longer need the lifecycles you don’t have to unwind any other abstractions, you just delete the &lt;Component/&gt;.</p><p>So there you have it. Obvious when you’ve seen it, tricky when you haven’t.</p><p>I’m going to be teaching more about these patterns, and explore future patterns like <a href="https://www.youtube.com/watch?v=v6iR3Zk4oDY">React Suspense</a> at my <a href="https://reach.tech/workshops">workshops</a>. Come join us!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c8e457a90e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/workshop-me/render-props-react-createcontext-but-how-9c8e457a90e3">Render Props, React.createContext … But How?</a> was originally published in <a href="https://medium.com/workshop-me">Workshop.me</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>