<?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[Code Daily - Medium]]></title>
        <description><![CDATA[We develop tutorials, screencasts, and courses to help you be a better developer. - Medium]]></description>
        <link>https://medium.com/codedaily?source=rss----b9923ca2afa5---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Code Daily - Medium</title>
            <link>https://medium.com/codedaily?source=rss----b9923ca2afa5---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:52:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/codedaily" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Fundamentals of Rendering Data as an SVG Line with D3 and scaleLinear]]></title>
            <link>https://medium.com/codedaily/fundamentals-of-rendering-data-as-an-svg-line-with-d3-and-scalelinear-ad5bf34c2873?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/ad5bf34c2873</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Fri, 16 Mar 2018 15:45:19 GMT</pubDate>
            <atom:updated>2018-03-16T15:45:18.816Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F260350173&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F260350173&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F689053438_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/742b307bd9d1046b37e0a7971cc71b84/href">https://medium.com/media/742b307bd9d1046b37e0a7971cc71b84/href</a></iframe><p>Visualizations can be intimidating. We’ll be focusing on the fundamentals. Nothing crazy, just drawing a line. We’ll explain everything that goes into taking your data, rendering it and making sure it fits inside your SVG, and then we’ll throw a little curve at the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*a_Vdwchjnst9xkVW.png" /></figure><h3>Install Dependencies</h3><p>First off D3 is the defacto standard for visualizations. It makes it easy to handle all the math, path building, etc and let React handle the rendering of it. We will use 2 packages from d3, the d3-shape library for building up our line path. Then the d3-scale that will handle the translation of our data to renderable numbers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0d225b4ab2a2aa59b6b4f4eb19ab2c5/href">https://medium.com/media/f0d225b4ab2a2aa59b6b4f4eb19ab2c5/href</a></iframe><h3>Data</h3><p>Our data is structured specifically for this tutorial. The x is just increasing by 1 each time and the y is increasing by 50 each time. This will cause nice steps and will be easy to show off how the path structure is actually built and translated from our data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0315a910efe8e9bfac7d08be0aada514/href">https://medium.com/media/0315a910efe8e9bfac7d08be0aada514/href</a></iframe><h3>Selectors</h3><p>These are our data selectors, just JavaScript functions. These aren’t special to D3 but it’s what we’ll use to select the piece of data for each x and y pointer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26605a90270f100c57218f3f3698e2ef/href">https://medium.com/media/26605a90270f100c57218f3f3698e2ef/href</a></iframe><p>Imagine if y wasn&#39;t your key but instead it was price. Well rather than d =&gt; d.y you&#39;d have used d =&gt; d.price. That way you don&#39;t have to pre-process your data and add x or y properties, we just use some selectors to grab values for us.</p><h3>Setup SVG</h3><p>First off we’ll define a width/height. When dealing with SVGs knowing the width/height is crucial. We’re defining it as 500 wide and 300 high. This will give us the ability to scale our data down.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b39c0adbd191d584ab7fb7da2279985f/href">https://medium.com/media/b39c0adbd191d584ab7fb7da2279985f/href</a></iframe><p>The outer wrapping &lt;div&gt; isn&#39;t necessary. The svg is given our width and height. We&#39;ll then place our svg paths inside of it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfa86443a815588d7b55e24791a4082c/href">https://medium.com/media/dfa86443a815588d7b55e24791a4082c/href</a></iframe><h3>scaleLinear</h3><p>First off we need to import scaleLinear from d3-scale.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e22f3c0adef7a1a4f313f4fd226fd142/href">https://medium.com/media/e22f3c0adef7a1a4f313f4fd226fd142/href</a></iframe><p>scaleLiner provides a way to create a range and a domain that are proportionally mapped. When give a value it has the ability to extrapolate in either direction. Mostly you are providing a value that is within the domain you have set. scaleLinear then extrapolates (fancy word for &quot;does some math&quot;) and figures out what the output value is based on the range you&#39;ve specified. Generally speaking the range will be the dimensions of the SVG you are rendering into.</p><p>The reason we need to scale our data is because the values of your data don’t necessarily coordinate to actual rendering pixels. Our SVG is 500x300, but what if it were 800x500? Or 100x30? The data is still the same but we need to extrapolate where each data point should be rendered based on the size of our SVG.</p><p>To read more about scaleLinear you can see what the documentation says about it here <a href="https://github.com/d3/d3-scale#scaleLinear">d3-scale#scaleLinear</a>.</p><p>So for our xScale. We are rendering from 0 to the width of our SVG which is 500. Our domain of our data is the minimum x value and the maximum x value. The positions in the array for the range, coordinate to the positions of the domain.</p><p>So if you call xScale in this instance and give it the value 0. It will return your 0. If you call it with the value 10, it&#39;s going to return you the 500 aka the width. Now if you passed in 5 it will see that it is halfway between 0 and 10 in the domain, and extrapolating between 0 and 500 will return 250.</p><p>The x axis is the horizontal axis, and will help us position our rendering left &lt;=&gt; right.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92733ea65508179d2bb0f26717f21278/href">https://medium.com/media/92733ea65508179d2bb0f26717f21278/href</a></iframe><p>So you can see here that all this scaleLinear is doing is some math based upon your dimensions (range) and your data (domain). We&#39;ve manually specified the array [0, 10] for our domain but this can be programmatically figured out using a min and or max function.</p><p>Now we’re onto our y axis which is our vertical axis which will help us in our rendering top &lt;=&gt; bottom.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be4ebb3b8c30cc213b9378da659040e4/href">https://medium.com/media/be4ebb3b8c30cc213b9378da659040e4/href</a></iframe><p>Our data range for our y parameter extends from 0 to 500. So just like before we setup our domain based upon our data. The range is setup based upon our height, which is 0 to 300 in this case.</p><p>For the x our data was easy it was numbers between 1 and 10. This is numbers between 0 and 500.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4be656f126a7be9768f3c86538c5be4/href">https://medium.com/media/e4be656f126a7be9768f3c86538c5be4/href</a></iframe><p>Our data is being scaled down this time to fit within the constraints of our 300 height.</p><p>Overall if you are rendering some graph data you’ll likely use scaleLinear to map your domain values to the range values to render within your svg.</p><h3>Build a Line</h3><p>Now we need to build up our line. So we’ll use the line function from d3-shape.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3994d55c90af9fe4284708e220b50b9f/href">https://medium.com/media/3994d55c90af9fe4284708e220b50b9f/href</a></iframe><p>We need to create a line and give an x and a y. What is going to happen is that our path that we create will eventually be given some data. Once it does it will loop over it and for each data point it called our x and y functions we specified.</p><p>Our x and our y first call their appropriate selectors. This will pluck off the value from each of our object structures that is structured like so { x: 1, y: 50}. Then we&#39;ll call our scaleLinear functions we setup. These will take the data value, and scale it to our renderable value. Then we&#39;ll return that to our line so it can figure out how we want our line created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/198c68c3725387d1561419897a991851/href">https://medium.com/media/198c68c3725387d1561419897a991851/href</a></iframe><p>Finally we call it with our data, and it will render our line. Don’t forget we need to give it a stroke of color, a strokeWidth which we set to 3, and tell it fill=&quot;none&quot; otherwise it&#39;ll fill in with black.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ebabe640c108735865551f7dbe29cde/href">https://medium.com/media/0ebabe640c108735865551f7dbe29cde/href</a></iframe><h3>Path</h3><p>If we take a look at what path(data) spits out it might be more clear about what&#39;s happening.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccbc7a729487437bf020d2fb44fadb5a/href">https://medium.com/media/ccbc7a729487437bf020d2fb44fadb5a/href</a></iframe><p>Those values sure do look familiar! Hey those are the exact values we were figuring out in the scaleLinear section up above.</p><p>The first is an M which will move to our first position from our data0,0. Then our next will draw a line to using L to our x and y. This is x=1 and y=50 in our data world. When mapped through our domain to our range it output 50,30. Rendering a line to the point x=50 and y=30.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*UL3ndRGJlEeJzdGf.png" /></figure><h3>Flip It</h3><p>When dealing with graphing 0 is the bottom left corner. However when dealing with SVG 0 is the top left corner. That&#39;s why when we our rendering our values it&#39;s starting in the top left corner.</p><p>We told it via our domain and range that 0 should map to 0.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3a471f1484113fae9cb813bded93550/href">https://medium.com/media/c3a471f1484113fae9cb813bded93550/href</a></iframe><p>Well if we wanted our 0 value to actually start at the bottom left corner we need to flip around range around. So 0 value is actually mapped to our height aka the bottom left corner, and our maximum value is actually 0 the top right.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59c2b2beaf4b16e7879d2a5135b997aa/href">https://medium.com/media/59c2b2beaf4b16e7879d2a5135b997aa/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/0*eb8b_B5QkMw8nCTJ.png" /></figure><h3>Up and Down Data</h3><p>We can also render different data. Lets map a pyramid like route, it’ll go up then down.</p><p>If you import the data</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/137b407d7f0fe8e3f04e62461e9cd5ce/href">https://medium.com/media/137b407d7f0fe8e3f04e62461e9cd5ce/href</a></iframe><p>It’ll look like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9018af47289ffacf2fd9d3a9f4af7c18/href">https://medium.com/media/9018af47289ffacf2fd9d3a9f4af7c18/href</a></iframe><p>Rather than the straight line data we need to fix our path call to take in our downUpData.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/965f60a5fe6af4fdfa3e5d969dafa2cf/href">https://medium.com/media/965f60a5fe6af4fdfa3e5d969dafa2cf/href</a></iframe><p>You can see that the path we created was just instructions on how to render data. It wasn&#39;t tied to any specific data. We can swap the data out and get a completely different result!</p><p>Now depending on what point you choose for your range either [0, height] or [height, 0] will change where it renders at.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/0*PtZY4XxfNG76xnxB.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*GcEDwGjnASJeC-Dc.png" /></figure><h3>Different Curves</h3><p>One final note is you can specify how the data curves. This will instruct the line how to build out the actual path to render.</p><p>We need to import it from d3-shape along with our line.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ae90489c995af8bf6a96acb71eddc21/href">https://medium.com/media/8ae90489c995af8bf6a96acb71eddc21/href</a></iframe><p>Then rather than just an x and a y we supply a curve. This will give a function that will effect how the final output path is constructed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/501b78cf20e77c7fa0f193091ade5998/href">https://medium.com/media/501b78cf20e77c7fa0f193091ade5998/href</a></iframe><p>You can see here there are a few more instructions compared to the previous path.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/775d6c1f857bbbdaa17aa5e32f0d283e/href">https://medium.com/media/775d6c1f857bbbdaa17aa5e32f0d283e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/0*BXZTV4N5n_Z1kjw6.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*1wIL7l566IxdD_xr.png" /></figure><h3>Ending</h3><p>Change around the width/height, see how the path is effected, see what it does to your line and how it renders.</p><p><em>Originally published at </em><a href="https://codedaily.io/tutorials/42/Fundamentals-of-Rendering-Data-as-an-SVG-Line-with-D3-and-scaleLinear"><em>Code Daily</em></a><em>.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development on <a href="https://codedaily.io/"><strong>Code Daily</strong></a>. Be sure and follow me on <a href="https://twitter.com/browniefed"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad5bf34c2873" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/fundamentals-of-rendering-data-as-an-svg-line-with-d3-and-scalelinear-ad5bf34c2873">Fundamentals of Rendering Data as an SVG Line with D3 and scaleLinear</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create an Optional Dynamic Validation Schema based on a Value with the Yup Validation…]]></title>
            <link>https://medium.com/codedaily/how-to-create-an-optional-dynamic-validation-schema-based-on-a-value-with-the-yup-validation-26b70f7a6d1c?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/26b70f7a6d1c</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[yup]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[validation]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Tue, 13 Mar 2018 16:04:54 GMT</pubDate>
            <atom:updated>2018-03-13T16:04:54.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Create an Optional Dynamic Validation Schema based on a Value with the Yup Validation Library</h3><p><a href="https://github.com/jquense/yup">Yup</a> is a JavaScript object schema validator and object parser inspired by Joi ( a validator for node). It has many powerful features like async validation, custom rules, stacking conditions based on other values through out your data, and dynamic run-time schema validation.</p><p>We’ll be talking about run-time schema validation. Essentially this lets you define validation rules on the fly when you are attempting to validate your data. This will let you implement all the crazy validation logic you’ll ever need for your forms!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F259796998&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F259796998&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F688345369_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/40040559794d518ef6be9d79e7fc2827/href">https://medium.com/media/40040559794d518ef6be9d79e7fc2827/href</a></iframe><h3>Scenario</h3><p>I encountered a scenario where sections of a form I was making were optional if omitted but required if they existed.</p><p>Essentially the data payload could be and empty object</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3fd095ebd60fc7207ae8f0854a4fb2b/href">https://medium.com/media/d3fd095ebd60fc7207ae8f0854a4fb2b/href</a></iframe><p>or</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3584d3f1cb6a67317ad57e37f66a2530/href">https://medium.com/media/3584d3f1cb6a67317ad57e37f66a2530/href</a></iframe><p>Where data1, or data2, or data3 could be defined as objects or just completely undefined. This made validation tricky as it required knowledge of the value at the given key location before you knew whether you needed to validate it. There are other intricacies that could exist as well. With more information certain sub-trees of data may or may not be required based on previous answers.</p><p>Overall I needed a quick way to use a value to determine whether or not data at a key needed validation.</p><h3>Quick Setup</h3><p>So we’re using React because why not? Yup can be used with any front end framework. We’ll setup a basic yup.object() and run isValidSync() and pass in our this.state.</p><p>The yup.object doesn&#39;t have any schema validations so valid is going to be true.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b840e5283b530e70dd42512a7fe9e2b8/href">https://medium.com/media/b840e5283b530e70dd42512a7fe9e2b8/href</a></iframe><p>The isValidSync will only return true or false. To get the actual errors you&#39;ll need to use the validateSync in combination with a try/catch.</p><h3>Defining Validation Schema</h3><p>In order to define validation rules we define a validation schema. This is a series of yup calls to build out an entire schema that will then be passed the data to validate.</p><p>Our first step is to define our outer wrapper. In our case because the wrapper is an object with nested data we use the yup.object() call and then tell yup we are going to define the shape of the data below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df235c6babfb111ece5a471900f59212/href">https://medium.com/media/df235c6babfb111ece5a471900f59212/href</a></iframe><p>Next we define a key on this shape called optionalObject. This will then match up with any data like so { optionalObject: {} }. We then define another yup.object().shape(). If we just did yup.object() it would just be looking for an object with no data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4692195f9f5517ed7e6695764186e0a8/href">https://medium.com/media/4692195f9f5517ed7e6695764186e0a8/href</a></iframe><p>Finally we define our required data. We’ll just call it otherData and indicate that it&#39;s a required string.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/986a9cae31eb365167e8dc39ed13b77b/href">https://medium.com/media/986a9cae31eb365167e8dc39ed13b77b/href</a></iframe><p>If we were to run this against our data it would not be valid.</p><h3>Make it Optional</h3><p>If we passed in our data that is just an empty object it would attempt to validate and tell us that we otherData string is required.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7456229a209a6226d5b84e293b0fb3b0/href">https://medium.com/media/7456229a209a6226d5b84e293b0fb3b0/href</a></iframe><p>Well what if we wanted this to be valid? Then if we passed in optionalObject actually defined then we would trigger our validation. This sort of strategy can make optional form validation easier since we can just add an {} or set whole subtrees to undefined.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb4e83c7f5a00f854d437ab6fccb3997/href">https://medium.com/media/bb4e83c7f5a00f854d437ab6fccb3997/href</a></iframe><p>To make this work we use the yup.lazy() function. It will get passed the value of the key you&#39;ve defined it on. When the yup.lazy() is run you are guaranteed the value to exist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6594cac4f48aea527718620e5db3c69/href">https://medium.com/media/d6594cac4f48aea527718620e5db3c69/href</a></iframe><p>We must always return at least some validation rule. So first off if value !== undefined then we&#39;ll return our previous validation schema. If it is undefined then we&#39;ll use the yup.mixed().notRequired() which will just inform yup that nothing is required at the optionalObject level.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16e4f29098993b2cb2e7e371fcd91513/href">https://medium.com/media/16e4f29098993b2cb2e7e371fcd91513/href</a></iframe><h3>Wire it Up</h3><p>Now if we just have our button add in our optionalObject subtree. We can</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/522f480c6fe6f24345545c5cd050d8ba/href">https://medium.com/media/522f480c6fe6f24345545c5cd050d8ba/href</a></iframe><p>Once toggled our validation re-runs, and we now see that optionalObject is set thus our validation will be returned from within the if statement of yup.lazy() and we&#39;ll now have a required otherData string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*IHjvqNua6g6fn5fy.gif" /></figure><h3>Final</h3><p><a href="https://github.com/jquense/yup">Yup</a> is a very powerful validation library with a ton of features. It can be used for the simplest of validations and accommodate anything you need to get done including async validation.</p><p><em>Originally published at </em><a href="https://codedaily.io/tutorials/41/How-to-Create-an-Optional-Dynamic-Validation-Schema-based-on-a-Value-with-the-Yup-Validation-Library"><em>Code Daily</em></a><em>.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development on <a href="https://codedaily.io/"><strong>Code Daily</strong></a>. Be sure and follow me on <a href="https://twitter.com/browniefed"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26b70f7a6d1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/how-to-create-an-optional-dynamic-validation-schema-based-on-a-value-with-the-yup-validation-26b70f7a6d1c">How to Create an Optional Dynamic Validation Schema based on a Value with the Yup Validation…</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make a Beautiful Interactive Bitcoin Price Chart with React, D3, and VX]]></title>
            <link>https://medium.com/codedaily/make-a-beautiful-interactive-bitcoin-price-chart-with-react-d3-and-vx-e8476510cb57?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/e8476510cb57</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Tue, 06 Mar 2018 21:38:42 GMT</pubDate>
            <atom:updated>2018-03-06T21:54:24.335Z</atom:updated>
            <content:encoded><![CDATA[<p>Interactive charts can seem intimidating. They were for me, and some still are but after spending time diving into them for work I’ve learned they aren’t as intimidating. There are a few key concepts we’ll go over that helped me unlock visualizations. It was the AHA! moment that I needed and I hope to teach you as well.</p><p>This is what we’re building, check out the <a href="https://codesandbox.io/s/github/codedailyio/bitcoin_chart">Live Demo</a> before you dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2TcS4-7zn-2YwrfKumdWQ.gif" /></figure><h3>Setup</h3><p>First thing we need to load our data. So it’s easier to work with we process it a little bit. We receive the data in a {&quot;2018-02-05&quot; : 9999, &quot;2018-02-06&quot;: 8888} structure which is more difficult to work with when you or a library needs to work on data with functional calls like .map.</p><p>We do that with this code here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd87d4dcf2cd28beed649c067a06a815/href">https://medium.com/media/fd87d4dcf2cd28beed649c067a06a815/href</a></iframe><p>Which takes the bpi (I assume bitcoin price index) and gets the keys. Those keys happen to be the date that we want. We&#39;ll map over all of it and return the date, and then our data.bpi[date] which is going to be our price. This all returns an array of objects like so.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f705a51cf133b9c9e658ead88b7d1eb/href">https://medium.com/media/5f705a51cf133b9c9e658ead88b7d1eb/href</a></iframe><p>Thanks to <a href="https://gist.github.com/coindesk.com">CoinDesk</a> for providing an API of data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3aa9f3689b95fff203dd2f91642041a/href">https://medium.com/media/f3aa9f3689b95fff203dd2f91642041a/href</a></iframe><h3>Add dependencies</h3><p>First thing we need to do is install our dependencies.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfa01756230c7a77bd493e5b9990331d/href">https://medium.com/media/cfa01756230c7a77bd493e5b9990331d/href</a></iframe><p>We’re using <a href="https://vx-demo.now.sh/">vx</a> a library from <a href="https://twitter.com/hshoff">https://twitter.com/hshoff</a> a developer at AirBnB.</p><p>We also add in d3-array and d3-time-format. vx does a lot but still requires us to do some low-level work. This might seem more difficult but it provides us with the ability to learn what&#39;s really happening, and also accomplish the exact chart we want versus other charting libraries that just spit out a default chart.</p><h3>Width/Height</h3><p>We do need to define width and height. This will be required for rendering our SVG, as well as determining how we need to render our data. This might be something more specific for you and your rendering needs but we’ll just render it the size of the screen. We use the window.innerWidth and window.innerHeight to get those values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21a3f6366f67c988bcfe9ad45b05c4ac/href">https://medium.com/media/21a3f6366f67c988bcfe9ad45b05c4ac/href</a></iframe><p>Additionally the padding is to give us some cushion on either sides. Without the padding the SVG rendering will go right up to the edge. That means our line will touch the edge and additionally our tooltips. Since SVGs will only show the content within the width/height that you&#39;ve defined it will cause our tooltips to be clipped. So just to be safe we give ourselves padding.</p><p>Here we’re defining our xMax and yMax. Those will become more clear in a second.</p><h3>Create a Green Square</h3><p>So lets get our work area setup. We create a wrapping div to render some additional tooltip elements later. We set out svg to our width and height we defined earlier. To render a rectangle in SVG land we use the rect element. We must define a few props.</p><p>First our x and y. This defines the top left corner of where we want to start rendering out rectangle. Then we define a width/height which will just be our entire SVG space. Finally so people can see it we fill it in with a color. This is equivalent to using background-color in CSS.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71a23ca67716c0e33c8d5ed7568b67d6/href">https://medium.com/media/71a23ca67716c0e33c8d5ed7568b67d6/href</a></iframe><p>So great. We now have a blank green square all setup taking up the entire screen!</p><h3>Setup Data Processors</h3><p>Now comes our data selectors.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44e446661c4bacc000aeb9dcfbea4be9/href">https://medium.com/media/44e446661c4bacc000aeb9dcfbea4be9/href</a></iframe><p>Here we are defining the bounds of our rendering outputs. We’ve set a yMax to be the entire height we have defined minus 100px. Same goes for the xMax.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26a6a4edc220cccd66dfe1f1eb7ef60c/href">https://medium.com/media/26a6a4edc220cccd66dfe1f1eb7ef60c/href</a></iframe><p>These are just JavaScript functions. They take in data as an object and return the selected value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f880ad147271af9dda2e5691003463f/href">https://medium.com/media/9f880ad147271af9dda2e5691003463f/href</a></iframe><p>Alright now comes a function you may have never seen before. This is from @vx/scale but is actually a helper method on top of d3-scale. So this is basically raw D3.</p><p>The scaleLinear receives a range and a domain. What this does is takes arrays of data and provides a way to take a value and preserve proportional differences and turn it into a renderable point. Not only can it take a value and get a renderable y value but also the reverse! More on that later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e782955e3cfef15eb76695a9316b16d7/href">https://medium.com/media/e782955e3cfef15eb76695a9316b16d7/href</a></iframe><p>Lets disect this further as it’s one of the most important concepts to grasp in rendering visualizations.</p><p>First our range: [yMax, padding]. We define the limit to be the yMax which is the height - padding and the final edge of our rendering abilities to be our padding.</p><p>The domain is the bounds of our data. We don&#39;t expect our prices to go below 0. Then we use the max from d3-array to loop over all our data. Provide it our ySelector which will get passed each data point and return the price. The max function will then return the top number it finds.</p><p>We then add some padding to the top of our data with a third of our maximum data.</p><p>The way this is setup with range and domain will map our yMax from our range to the first piece of the domain array. So if our yMax is 800, and we ask yScale where to render a price of $0. It would say at 800. Which would be the BOTTOM of the SVG.</p><p>Now what if we our dataMax was 15,000 and we asked yScale where to render? It would return our padding which is 100 and the TOP of the SVG. Well this is sort of true, we added an extra 5000 (15000/3) to the top so yScale would figure out the extra coordinate to render at.</p><p>Hopefully you’re seeing the the power now. A scale function allows us to define the bounds of our chart, and connect it to the data in a proporotional manner. So if the size of SVG changes our data points will still be scaled and rendered in the correct spots.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32fd80ae1e79045a81287e4f04fcf642/href">https://medium.com/media/32fd80ae1e79045a81287e4f04fcf642/href</a></iframe><p>Now the same goes for xScale here as it did for yScale. However we&#39;re using scaleTime rather than scaleLinear as it&#39;s built for handling dates.</p><p>Some solutions you may observe might use the index of the array item for x. However this just means to render you need to do a data lookup. D3 provides helper methods to do this that are even more powerful.</p><p>The scaleTime would allow you to ask about ANY date within the domain range and where to render it exactly. If we used an integer here we would only ever be able to render the exact dates provided via the data. We aren&#39;t going to use this power but it&#39;s good to know about.</p><p>We use extent which returns the top and bottom dates. The output of the extent call would be an array of 2 dates, [earliestDate, lastDate].</p><h3>Create a “LinePath”</h3><p>Now that we understand the data processors we setup lets use them. LinePath is a helper shape from vx. It takes an array of data ( our bitcoin prices), our scales, and our selectors.</p><p>It will loop over each piece of data, use our xSelector/ySelector to get the data point, then it will pass it to our xScale/yScale to find the exact pixel coordinates to render to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54bafa41e7e10a6cfd78b733afdc9362/href">https://medium.com/media/54bafa41e7e10a6cfd78b733afdc9362/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GGFW3lcG7zJ6h18r.png" /></figure><h3>Bar to Catch Mouse Movements</h3><p>We need a way to catch all mouse events. We render a Bar on top of the entire SVG. This is equivalent to using a rect element it adds some helper injection. It looks through all the props and if it detects a function like onMouseMove it will wrap it and pass through the data. We have easy access to our data but there may be a time when you don&#39;t.</p><p>This will ensure you have access to your data for all of your events. That’s also the reason for this data =&gt; event =&gt;. A function that returns a function. We put our data in scope, return an event handling function that will get called with the event and then do something with it.</p><p>In our case we want to show/hide tooltips.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5cdffdf5cf45b9db4aa887d59197f7d/href">https://medium.com/media/b5cdffdf5cf45b9db4aa887d59197f7d/href</a></iframe><p>Now the reason we add this Bar in is so that we have an entire area to catch our mouse movements. If we attached them to the LinePath we&#39;d only get them when they are directly with in the bounds of our line like so. You can see that is a very limited area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tRh4G6g0HQ_Bhlw6.png" /></figure><p>If we place them on our Bar we get the entire area of mouse movement events and can generate a much better experience for our users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d0ehsde-IW41IhQx.png" /></figure><h3>Tooltip Handler</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a990a75edc2b798eedaf52ec822536a7/href">https://medium.com/media/a990a75edc2b798eedaf52ec822536a7/href</a></iframe><p>localPoint is just a helper method.</p><p>The invert method is from xScale. This is what I was previously talking about reversing from a rendered pixel coordinate to an actual value. What this will do is take our mouse coordinate, ask our xScale that given a specific rendered coordinate what is the value that would produce that.</p><p>In our case it’s going to return a date. So rather than taking a value and turning into pixel coordinates, it takes a pixel coordinate and turns it back into a value we can use.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4121d12fb0917badcd080e4d1a6284d0/href">https://medium.com/media/4121d12fb0917badcd080e4d1a6284d0/href</a></iframe><p>Another function from D3! What is this magical bisector and what does it do? Well the real intention is for when you&#39;re inserting data.</p><p>We create a bisector, tell it what data to look for and in our case we just give it our xSelector to get the date.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8acccf062ac672c15d258277d20bd3b0/href">https://medium.com/media/8acccf062ac672c15d258277d20bd3b0/href</a></iframe><p>Here is a quick example. Given [1,2,3,4,5,6] and I asked you to add 2.5 to this array, where would it go? Well it would go here [1,2,2.5,3,4,5,6] at index 2.</p><p>What if I asked you to add 3 instead? It could go at index 2, or at index 3! Well that&#39;s what the .left indicates. You can either choose left or right. Left would give you 2 or right would give you 3.</p><p>We aren’t using it for insertions though. We’re using it so we can determine what price we’re close to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22dff266e70ed9842bfb00d55a6a2b83/href">https://medium.com/media/22dff266e70ed9842bfb00d55a6a2b83/href</a></iframe><p>Given our data, and a date from our xScale.invert we want to know what data point our mouse is currently close to. The ending 1 to the bisectDate call is just saying to never return an index less than 1.</p><p>Now that we have our index we need to know which point we are closer to. If we don’t do this math we will have to be directly over specific values and also won’t ever be able to hover over index 0.</p><p>We get our 2 possible data points and store them as d0 and d1. Then if we have a second data point we need to compare which one is closer to our mouse.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a98b3ce546adca010bb3d2baee8c5ae8/href">https://medium.com/media/a98b3ce546adca010bb3d2baee8c5ae8/href</a></iframe><p>The absolute key thing here is that x0 is a date. It&#39;s a date returned from xScale.invert. It&#39;s not necessarily a date that is in our data set. It&#39;s a date that our xScale figured out from a pixel coordinate.</p><p>When we do x0 - xSelector(d0) what&#39;s happening is it&#39;s becoming x0 - new Date(&quot;2018-02-05&quot;) which with the magic of JavaScript coercion turns into x0 - 1517788800000. So When we replace our x0 with a mouse coordinate we can determine whether or not our data point 0 or data point 1 is closer to the mouse.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bd902e90792f1a482427eff6fa789cf/href">https://medium.com/media/2bd902e90792f1a482427eff6fa789cf/href</a></iframe><p>Finally we’ll call showTooltip with our data. We have our data point d. Then in order to determine the x and y points to render our tooltip at we use our x/y Selectors to get our values (date/price) and then ask our x/y Scale what the coordinates it should be rendered at.</p><p>We haven’t set this up yet but it’s provided by vx and we&#39;ll setup all up next.</p><h3>Setup Tooltip Display</h3><p>First off we need to import our withTooltip HOC and Tooltip from vx. Additionall we destructure some injections from our withTooltip HOC.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c6e54bd56a3adbf13fca88c0d9fd6a0/href">https://medium.com/media/7c6e54bd56a3adbf13fca88c0d9fd6a0/href</a></iframe><p>The withTooltip surrounds our App component with a &lt;div&gt; element with position: relative set on it so we can render absolutely positioned elements easier. Also it adds in showTooltip, hideTooltip, tooltipData, tooltipTop, tooltipLeft so we can hold state up above easier and have it injected into our component as props thus making it available everywhere.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f59037105ebbf30c4ed269ed5c028f5a/href">https://medium.com/media/f59037105ebbf30c4ed269ed5c028f5a/href</a></iframe><p>Then attach onMouseMove and onMouseLeave to our Bar. When we leave our SVG we&#39;ll hide our tooltip, and while it&#39;s moving over the top we&#39;ll call handleTooltip with all necessary info.</p><p>The reason we need to pass in our xScale/yScale is those are defined in render and not available in our handleTooltip function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3e590b51c4dc470c465fc04c6dfdf01/href">https://medium.com/media/b3e590b51c4dc470c465fc04c6dfdf01/href</a></iframe><p>Inside our SVG we want to render a Line indicating what data point we are at. This is done by defining a from and a to which are coordinates. These are what we used all the work in our handleTooltip call to figure out.</p><p>The x for both will be at the same point because we&#39;re rendering at a specific spot horizontally. We then need to tell our Line to stretch from the top to the bottom. We do that using 0 for the top and our yMax as the bottom of the svg.</p><p>We also render a circle at the specific data point on the line. Both Line and our circle have some general styling applied. This can be changed by you to meet whatever your styling desires are. Notice also we&#39;re not rendering any text values, just shapes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6751f6b36d8552fe39bfcfe71da3a29a/href">https://medium.com/media/6751f6b36d8552fe39bfcfe71da3a29a/href</a></iframe><p>Then outside our SVG we render our tooltips. This is a div that has some styling and is absolutely positioned. We provide the first Tooltip with our price and position it where our data point is (minus some offset so it doesn&#39;t cover our circle) and provide some additional styling.</p><p>Same goes for our Tooltip to render our date. We pass in our tooltipData to our xSelector then to a formateDate function we created. This uses the timeFormat from D3 to take a date and render it in a human readable fashion.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6de4bf5b6c9a1fc5bb3cb7c3b86b2334/href">https://medium.com/media/6de4bf5b6c9a1fc5bb3cb7c3b86b2334/href</a></iframe><h3>Mobile</h3><p>To make this work on mobile, don’t forget to wire up touch events. These are equivalent of the mouse events but will register when users use their fingers to touch the graph.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4c93a1289e0d44879772eb9de9e550b/href">https://medium.com/media/b4c93a1289e0d44879772eb9de9e550b/href</a></iframe><h3>Pre-Ending</h3><p>This is may seem extremely complicated but breaking down a visualization into it’s pieces and figuring those out separately will help you achieve any other visualization.</p><p>We first rendered a square, then how to translate our data, then rendered it as a LinePath. Next was to make it interactive. We got a Bar wired up to catch mouse coordinates, figured out where to render, then finished up by rendering our Tooltip and interactive works.</p><h3>Ending</h3><p>The <a href="https://gist.github.com/vx-demo.now.sh">vx</a> library adds a nice mix between helping you render data and letting you choose how it is rendered to achieve the exact interactive visualization that you want.</p><p>If you want to play with it live you can check out the <a href="https://codesandbox.io/s/github/codedailyio/bitcoin_chart">Live Demo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rViBVyrQVLAvjuC5mNBvQ.png" /></figure><p><em>Originally published at </em><a href="https://codedaily.io/tutorials/39/Make-a-Beautiful-Interactive-Bitcoin-Price-Chart-with-React-D3-and-VX"><em>Code Daily</em></a><em>.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8476510cb57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/make-a-beautiful-interactive-bitcoin-price-chart-with-react-d3-and-vx-e8476510cb57">Make a Beautiful Interactive Bitcoin Price Chart with React, D3, and VX</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding setState in componentDidMount to Measure Elements Without Transient UI State]]></title>
            <link>https://medium.com/codedaily/understanding-setstate-in-componentdidmount-to-measure-elements-without-transient-ui-state-b949d8f83825?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/b949d8f83825</guid>
            <category><![CDATA[learn-react-js]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Thu, 01 Mar 2018 04:38:47 GMT</pubDate>
            <atom:updated>2018-03-01T04:38:47.316Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F258021544&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F258021544&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F686091424_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a8f5b1bfd95038ed8dc4318531c8bfa/href">https://medium.com/media/0a8f5b1bfd95038ed8dc4318531c8bfa/href</a></iframe><p>In this lesson we’ll explore using setState to synchronously update in componentDidMount. This allows for us to use getBoundingClientRect or other synchronous UI calls and make changes to the UI without a transient UI state.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/67/Understanding-setState-in-componentDidMount-to-Measure-Elements-Without-Transient-UI-State"><em>codedaily.io</em></a><em> on March 1, 2018.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b949d8f83825" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/understanding-setstate-in-componentdidmount-to-measure-elements-without-transient-ui-state-b949d8f83825">Understanding setState in componentDidMount to Measure Elements Without Transient UI State</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Yarn Workspaces to Share Code with a create-react-app and create-react-native-app in a Monorepo]]></title>
            <link>https://medium.com/codedaily/use-yarn-workspaces-to-share-code-with-a-create-react-app-and-create-react-native-app-in-a-monorepo-aa68da7dc3c?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/aa68da7dc3c</guid>
            <category><![CDATA[workspace]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[yarn]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Wed, 28 Feb 2018 17:38:54 GMT</pubDate>
            <atom:updated>2018-02-28T17:38:53.747Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F257840856&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F257840856&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F685860455_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/a99232c3cd748d9ed5d270050f40104b/href">https://medium.com/media/a99232c3cd748d9ed5d270050f40104b/href</a></iframe><p>In this lesson we’ll use yarn and yarn workspaces to create a monorepo that includes a web creat-react-app, a react-native app, and shared code. We’ll use react-app-rewired and react-app-rewire-babel-loader to rewire the create-react-app configuration to allow babel to process the shared code from workspace. We&#39;ll also use crna-make-symlinks-for-yarn-workspaces and metro-bundler-config-yarn-workspaces to configure the react-native app to be able to find the shared code in the workspaces.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/66/Use-Yarn-Workspaces-to-Share-Code-with-a-create-react-app-and-create-react-native-app-in-a-Monorepo"><em>codedaily.io</em></a><em> on February 28, 2018.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa68da7dc3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/use-yarn-workspaces-to-share-code-with-a-create-react-app-and-create-react-native-app-in-a-monorepo-aa68da7dc3c">Use Yarn Workspaces to Share Code with a create-react-app and create-react-native-app in a Monorepo</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contain an Animation within the Screen Dimensions in React Native]]></title>
            <link>https://medium.com/codedaily/contain-an-animation-within-the-screen-dimensions-in-react-native-2d31ddbfe673?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/2d31ddbfe673</guid>
            <category><![CDATA[animate]]></category>
            <category><![CDATA[animated]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 20:27:46 GMT</pubDate>
            <atom:updated>2018-02-28T17:39:10.622Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F256901761&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F256901761&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F684689421_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/84601cf640d9bebd3b272b8f2003e067/href">https://medium.com/media/84601cf640d9bebd3b272b8f2003e067/href</a></iframe><p>In this lesson we’ll use the screen Dimensions and anAnimated.ValueXY to create an animated element that when animated is contained within the screen dimensions. It uses the extrapolate: &quot;clamp&quot; feature of interpolate.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/65/Contain-an-Animation-within-the-Screen-Dimensions-in-React-Native"><em>codedaily.io</em></a><em> on February 22, 2018.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d31ddbfe673" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/contain-an-animation-within-the-screen-dimensions-in-react-native-2d31ddbfe673">Contain an Animation within the Screen Dimensions in React Native</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Course] Creating a React Native Animated Number Ticker]]></title>
            <link>https://medium.com/codedaily/course-creating-a-react-native-animated-number-ticker-4abc205e5699?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/4abc205e5699</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 20:27:08 GMT</pubDate>
            <atom:updated>2018-02-28T17:39:29.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*YDVX5FDYcekOP01XAzwqZw.jpeg" /><figcaption>Rotating Number Ticker</figcaption></figure><p>In this lesson we’ll walk through the effects of overflow: &quot;hidden&quot;. With onLayout we can measure elements even though they are hidden with opacity. Finally we&#39;ll show how we can render hidden elements and control what is visible with a translate.</p><h3>Measuring and Creating Hidden Elements with Translate Offsets in React Native</h3><p>In this lesson we’ll walk through the effects of overflow: &quot;hidden&quot;. With onLayout we can measure elements even though they are hidden with opacity. Finally we&#39;ll show how we can render hidden elements and control what is visible with a translate.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F254435215&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F254435215&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F681583043_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/412143910833c34cf9902b5ade30b92d/href">https://medium.com/media/412143910833c34cf9902b5ade30b92d/href</a></iframe><h3>Abstract Logic to a Reusable Component and Understand Component Reuse in React Native</h3><p>In this lesson we’ll abstract our code into a reusable Tick component. We’ll explore how React will update existing component instances and give us access to necessary data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F254434801&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F254434801&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F681582300_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/36a7188bb8b1623c5a97f6974fc608c9/href">https://medium.com/media/36a7188bb8b1623c5a97f6974fc608c9/href</a></iframe><h3>Animating Offsets when Values Change in React Native</h3><p>In this lesson we’ll see how we can use the componentDidUpdate lifecycle method combined with an animation to create the rotating number effect.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F254434619&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F254434619&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F681582000_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9b11f746b55d5b9249fdc1dc4957efc/href">https://medium.com/media/b9b11f746b55d5b9249fdc1dc4957efc/href</a></iframe><p><em>Originally published at </em><a href="https://codedaily.io/courses/6/Creating-a-React-Native-Animated-Number-Ticker"><em>codedaily.io</em></a><em> on February 6, 2018.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4abc205e5699" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/course-creating-a-react-native-animated-number-ticker-4abc205e5699">[Course] Creating a React Native Animated Number Ticker</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Detect Touch Inactivity with a PanResponder in React Native]]></title>
            <link>https://medium.com/codedaily/how-to-detect-touch-inactivity-with-a-panresponder-in-react-native-4a6c33508ee1?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/4a6c33508ee1</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[panresponder]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 19:06:18 GMT</pubDate>
            <atom:updated>2018-02-28T17:39:40.804Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F253732778&amp;dntp=1&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fvimeo.com%2F253732778&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fi.vimeocdn.com%2Fvideo%2F680699231_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c06f2e07c134ff3390ab5507c75be1b/href">https://medium.com/media/3c06f2e07c134ff3390ab5507c75be1b/href</a></iframe><p>In this lesson we’ll use the <em>onMoveShouldSetPanResponderCapture</em> from <em>PanResponder</em> to register touches with out stealing touches from other PanResponders. We can detect use this method to detect inactivity. This technique can be used for things like video players with auto-hiding controls.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/61/How-to-Detect-Touch-Inactivity-with-a-PanResponder-in-React-Native"><em>codedaily.io</em></a><em> on February 5, 2018.</em></p><h3>Closing Notes:</h3><p>I publish articles and screencasts weekly on React, React Native, and everything else related to web development. Be sure and follow me on <a href="https://twitter.com/codedailyio"><strong>Twitter</strong></a>.</p><p>Join our <a href="https://codedaily.io/newsletter"><strong>Newsletter</strong></a> to get the latest and greatest content to make you a better developer.</p><p>Check out my course and you too can master <a href="https://reactnativeanimations.com/"><strong>React Native Animations</strong></a>! Use the coupon code: codedaily for 60% off!</p><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a6c33508ee1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/how-to-detect-touch-inactivity-with-a-panresponder-in-react-native-4a6c33508ee1">How to Detect Touch Inactivity with a PanResponder in React Native</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Video that Auto Plays when Scrolled into View in React Native]]></title>
            <link>https://medium.com/codedaily/create-a-video-that-auto-plays-when-scrolled-into-view-in-react-native-198ab68f1f02?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/198ab68f1f02</guid>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Wed, 21 Jun 2017 15:39:32 GMT</pubDate>
            <atom:updated>2017-06-21T15:39:31.868Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F220041170&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F220041170&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fi.vimeocdn.com%2Fvideo%2F637951984_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/6890e02ed2f7c3ed0bee04fb926b5cc7/href">https://medium.com/media/6890e02ed2f7c3ed0bee04fb926b5cc7/href</a></iframe><p>In this lesson we’ll setup a react-native-video player that is paused when it is not visible but when scrolled into view starts playing the video. We&#39;ll also show how to add a small ending threshold so once the video is only partially out of view it will pause.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/33/Create-a-Video-that-Auto-Plays-when-Scrolled-into-View-in-React-Native"><em>codedaily.io</em></a><em> on June 4, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=198ab68f1f02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/create-a-video-that-auto-plays-when-scrolled-into-view-in-react-native-198ab68f1f02">Create a Video that Auto Plays when Scrolled into View in React Native</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Looping Background Video with React Native Video]]></title>
            <link>https://medium.com/codedaily/create-a-looping-background-video-with-react-native-video-79ba4d91c456?source=rss----b9923ca2afa5---4</link>
            <guid isPermaLink="false">https://medium.com/p/79ba4d91c456</guid>
            <category><![CDATA[stylesheets]]></category>
            <category><![CDATA[react-native-video]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Jason Brown]]></dc:creator>
            <pubDate>Tue, 20 Jun 2017 16:04:01 GMT</pubDate>
            <atom:updated>2017-06-20T16:04:00.884Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F220031234&amp;url=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttps%2Fplayer.vimeo.com%2Fvideo%2F220031234&amp;image=https%3A%2F%2Fblue-sea-697d.quartiers047.workers.dev%3A443%2Fhttp%2Fi.vimeocdn.com%2Fvideo%2F638165072_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/bce3ec8919e7e1d1d0931c9ea0d9f435/href">https://medium.com/media/bce3ec8919e7e1d1d0931c9ea0d9f435/href</a></iframe><p>In this lesson we’ll show how to use React Native Video to cover the entire background. We’ll use the repeat property, and also the helper StyleSheet.absoluteFill property so we do not need to replicate styles. We&#39;ll then show how to place a login form on top of the looping video.</p><p><em>Originally published at </em><a href="https://codedaily.io/screencasts/32/Create-a-Looping-Background-Video-with-React-Native-Video"><em>codedaily.io</em></a><em> on June 4, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79ba4d91c456" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codedaily/create-a-looping-background-video-with-react-native-video-79ba4d91c456">Create a Looping Background Video with React Native Video</a> was originally published in <a href="https://medium.com/codedaily">Code Daily</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>