<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kirsten Werner on Medium]]></title>
        <description><![CDATA[Stories by Kirsten Werner on Medium]]></description>
        <link>https://medium.com/@kirstenmwerner?source=rss-76a8a8384346------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*C6Axpe5-DW5vLE9fakKTXQ.jpeg</url>
            <title>Stories by Kirsten Werner on Medium</title>
            <link>https://medium.com/@kirstenmwerner?source=rss-76a8a8384346------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:04:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kirstenmwerner/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Simple Git commands cheat sh]]></title>
            <link>https://medium.com/@kirstenmwerner/simple-git-commands-cheat-sh-2d569554f33c?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d569554f33c</guid>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 09 Dec 2019 07:07:26 GMT</pubDate>
            <atom:updated>2019-12-09T07:07:26.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple Git commands cheat sheet</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d569554f33c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So what’s the deal with Binary?]]></title>
            <link>https://medium.com/kirsten-werner/so-whats-the-deal-with-binary-3d8c2fe94348?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d8c2fe94348</guid>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 02 Dec 2019 07:18:49 GMT</pubDate>
            <atom:updated>2019-12-11T21:18:57.875Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*snv9IlOwgm2Es4sT.jpg" /></figure><p>LONG before anyone gets involved in actual software engineering, or computer science, or any tech at all, we’ve mostly all heard of binary. We know the simple explanation — it’s how computers speak! But I found myself wondering what in the world does that mean? Embarrassingly far into my journey into software engineering, I found myself still having little to no understanding of what this robot language of 1’s and 0’s worked at all…..so here’s my simple breakdown of what it is.</p><p>I know what the word binary means both from my educational background in the sciences (hello, biological charts) and from the social/political climate we are in now (non-binary? you’d have to be living under a rock to not know what someone means when they tell you that they identify as non-binary) — it’s having specifically two distinct options. According to Oxford Dictionary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AX2IkVCi3KccEwp0TeQdHg.png" /></figure><p>So what does that mean in terms of numbers? By the second definition up above, a binary system of numbers is one that is defined by a base 2, rather than a base 10. This means that, where our common numerical system (which is base 10, or decimal) has these digits to choose from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*emH1NPu8gqky_CNj.jpg" /></figure><p>As we count up from 0, we have 10 digits to move through before adding a precursor to hold our tens place. If you imagine a zero in before the number, it would look like this:</p><h3>00, 01, 02, 03, 04, 05, 06, 07, 08, 09</h3><p>When you reach 09, and have no more available digits to use, you simply increase the starting zero to a one and begin your upwards count again:</p><h3>10, 11, 12, 13, 14, 15, 16, 17, 18, 19</h3><p><em>(I KNOW that I am explaining a reeeeaaallly simple concept here, but going through it again helped me wrap my head around binary)</em></p><p>Binary, however is a base 2 system, meaning that there are only two digits to work with, <strong>0 and 1. </strong>This system was developed by Gottfried Leibniz in 1689, but is the basis of all modern computing.</p><p>Using the same logic as above, you would move through counting upwards in binary like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*WDyQyIFA4eWmCGMuL_sTmg.png" /></figure><p>Each digit is referred to as a ‘bit’, so in the above counting example, we are looking at 7 bits. Binary can also be read <em>from right to left</em>, with each position representing 2 raised to the nth power, moving from 0 upwards as you move left. The values are then added together to get the total value of the binary number, translated to decimal. In the example below, we get the total value by reading the chart from <em>right to left</em> and adding each column’s value to that of the previous column: (8+32+64) = 104. As you can see, we do not count the <a href="https://www.computerhope.com/jargon/b/bit.htm">bits</a> with a 0 because they’re “turned off.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9F1kTV-y1u-5g1I9NyIG_A.png" /></figure><p>So why is this base 2 system of counting useful for computing? Nearly (super duper nearly) all modern electronics run off of transistors (short for ‘transfor resistors’), that have two states — ON or OFF. These states can be read as ON=1 and OFF=0. This physical representation of numbers inside the computing box can be translated into binary to control boolean logic.</p><p>Using this simple binary language has many benefits for computer programming:</p><ul><li>It is simple and elegant.</li><li>Binary’s 0 and 1 method is quick to detect an electrical signal’s off or on state.</li><li>The positive and negative poles of magnetic <a href="https://www.computerhope.com/jargon/m/magnmedi.htm">magnetic media</a> are quickly translated into binary.</li><li>Binary is the most efficient way to control logic <a href="https://www.computerhope.com/jargon/c/circuit.htm">circuits</a>.</li></ul><p>So, while there are other methods for for computer programming in theory (or, in some cases, in testing) binary remains the most simple and usable system that we have right now.</p><p>Hopefully this cleared up as much confusion for you as it did for me….and if not, thanks for sticking around through my working through my own confusion.</p><p>Happy coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/0*UWX1j6eeL9yZqOUu.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d8c2fe94348" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/so-whats-the-deal-with-binary-3d8c2fe94348">So what’s the deal with Binary?</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Toggling between different languages in your React website]]></title>
            <link>https://medium.com/kirsten-werner/toggling-between-different-languages-in-your-react-website-18e2497532e1?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/18e2497532e1</guid>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 25 Nov 2019 07:47:30 GMT</pubDate>
            <atom:updated>2019-11-26T02:46:54.017Z</atom:updated>
            <content:encoded><![CDATA[<h3>Toggling between different languages in a React website</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nGnnt3QLCfANxbV0.jpg" /><figcaption>Tower of Babel</figcaption></figure><p>Lately I’ve been working on a project with a group of my formal classmates to build a website for a company that is teaching womxn to code in Ecuador. This is the first full scale, in depth, functioning web site that I’ve had the pleasure to be a part of — and it has presented endless challenges and new skills for us to conquer as a group. From the sheer volume of files to organize in our file tree in a way that makes sense, to handling the responsiveness so that the site looks right on both desktop and mobile, to creating a sticky header that is easy to access even when the user has scrolled down the page, to figuring out the most intuitive way to add access points within the site for the user to contact the company. Being that this specific site is being designed for a company working predominately in Ecuador, a challenge presented itself to us that I found very interesting — how do we make this site accessible for both our English and our Spanish speaking users?</p><p>As we’d already been designing aspects of our UX/UI using Semantic UI, we decided to use a Semantic UI Dropdown component to list our user’s language options, and create a new component specifically for the language toggle that would then be available to import into our Header component (or anywhere else on the site that we might have decided would be a good fit).</p><pre>import React from &quot;react&quot;;<br>import { Dropdown } from &quot;semantic-ui-react&quot;;</pre><pre>const languageOptions = [<br>   { key: &quot;English&quot;, text: &quot;English&quot;, value: &quot;EN&quot; },<br>   { key: &quot;Spanish&quot;, text: &quot;Spanish&quot;, value: &quot;ES&quot; }<br>];</pre><pre>const LanguageToggle = props =&gt; {<br>   return (<br>      &lt;Dropdown<br>         button<br>         className=&#39;icon&#39;<br>         floating<br>         labeled<br>         icon=&#39;world&#39;<br>         options={languageOptions}<br>         search<br>         text=&#39;Select Language&#39;<br>         onChange={handleChange}<br>      /&gt;<br>   );<br>};</pre><pre>export default LanguageToggle;</pre><p>As you can see in the code above, we knew from the get go that we would obviously need to have an onChange function in place to deal with what happens when a user selects one of the languages available, but what that onChange function needed to do required a bit of brainstorming. The first thing that came to mind, was that we’d need to set the language selection in the state of our component, and then be able to send that state around as props to whichever components we wanted to access it. This, we discovered, would require using React’s Redux library, and setting up a reducer. So the next few steps were…</p><ol><li>Create a file in our reducers folder for our language reducer.</li></ol><pre>export default function languageReducer(state = { language: &quot;EN&quot; }, action) {<br>   switch (action.type) {<br>      case &quot;SET_LANGUAGE&quot;:<br>         let x = { ...state, language: action.setLanguage };<br>         return x;<br>      default:<br>         return state;<br>   }<br>}</pre><p>2. Import the connect function from the Redux store to our languageToggle file.</p><pre>import { connect } from &quot;react-redux&quot;;</pre><p>3. Still in the languageToggle file, add mapDispatchToProps function so that we can hit our reducer action, and then add mapStateToProps function so that our state becomes available as props from other components. <em>Make sure to add these functions underneath the closing curly boi (}) of the languageToggle const.</em></p><pre>const mapDispatchToProps = dispatch =&gt; ({<br>   setLanguage: language =&gt; dispatch({ type: &quot;SET_LANGUAGE&quot;, language })<br>});</pre><pre>const mapStateToProps = state =&gt; {<br>   return { language: state.language };<br>};</pre><p>4. Use Redux connect to get all of this stuff working together by changing our export default at the bottom of the file.</p><pre>export default connect(mapStateToProps, mapDispatchToProps)(LanguageToggle);</pre><p>5. And finally, write an onChange function to handle the user selecting a language. <em>This function should be under the declaration of the languageToggle const, but above the return.</em></p><pre>const handleChange = (event, data) =&gt; {<br>   props.setLanguage(data.value);<br>};</pre><p>Awesome — this all looks like it should work! Because all of us working on this site are English speakers, all of the text on the site up until this point had been written in English. So the next step was to decide how we wanted to go about adding in the Spanish text. We toyed with the idea of adding Spanish options for the text and logic to decide between English and Spanish in each and every component…..but…..ew. That would make every single component cluttered and messy, so No Thank You. The solution that we came up with was to move ALL of the text out into separate components that would export an object with keys pointing toward the language that we wanted to display. Depending on various situations — the size of your site, the number of people contributing to the content, the complexity of the content — you might find it easier and/or cleaner to use a backend to store your text data. For the purpose of our site (for now), we chose to simply create another folder within the src folder of our file tree, and to mirror the file structure of our features folder in order to store the text data for the various pages and components of our website. Each of these text data files would be .js files, with the data set up in json format (although not actual json, since we’re running strictly front end).</p><p>Once the file structure was ironed out, we needed to decide on the actual structure of our data. We first played around with the idea of each text data file object containing two keys: one “EN” and one “ES”, and then those keys containing objects pointing to whichever specific text we needed to store there. After much consideration, we realized that this organization method could potentially lead to trouble down the road, because anyone adding new text would have to remember to add it to both the “EN” key <strong>and</strong> to the “ES” key, and to keep the format and object keys the same within those two in order to avoid error on the server side. We also realized that some of the data about certain things would necessarily have to change between the English and Spanish versions, like id number or images, so having the data separated in that way could lead to a lot of repetitiveness. (Honestly, all of that is a good argument to move the data out into a database on the backend….maybe a refactoring project for our site on another day….)</p><p>In the end (for now), we decided that having whichever text data sections we needed to have available in both languages should each be available as objects in whichever text data file mirrored their features component file, and within THOSE objects, have keys signifying “EN” or “ES”. An example of a simple text data file with only one object is below:</p><pre>import React from &quot;react&quot;<br>import { Link } from &quot;react-router-dom&quot; </pre><pre>export const ourStoryText = { <br>   EN: {  <br>      goldTitle: &quot;Our&quot;,  <br>      navyTitle: &quot; Story&quot;,  <br>      text: (   <br>         &lt;div&gt;    <br>            &lt;p&gt;     <br>               <em>text in English</em><br> <br>               &lt;a href=&quot;/resources/research&quot;&gt;      <br>                   &lt;strong&gt;See the research.&lt;/strong&gt;     <br>               &lt;/a&gt;    <br>            &lt;/p&gt;    <br>            &lt;br /&gt;   <br>         &lt;/div&gt;  <br>      ), <br>   },  <br>   ES: {  <br>      goldTitle: &quot;Nuestra&quot;,  <br>      navyTitle: &quot; Historia&quot;,  <br>      text: (   <br>         &lt;div&gt;    <br>            &lt;p&gt;     <br>               <em>text in Spanish</em>    <br>            <br>               &lt;a href=&quot;/resources/research&quot;&gt;      <br>                   &lt;strong&gt;<em>text in Spanish</em>&lt;/strong&gt;     <br>               &lt;/a&gt;    <br>            &lt;/p&gt;    <br>            &lt;br /&gt;   <br>         &lt;/div&gt;  <br>      ), <br>   },<br>}</pre><p>The very cool thing to notice in this file, is that if you import React (and any specific things from it that you want), you can use JSX to style your text right here in the text files — even further cleaning up your features components!</p><p>FINALLY, we could replace the text in our original feature components with dynamic variables that we import from our text files….</p><pre>import React from &quot;react&quot;<br>import { ourStoryText } from &quot;../../common/aboutText/ourStoryText&quot;</pre><pre>const OurStory = () =&gt; {<br>   return (<br>      &lt;div className=&quot;about-bubble&quot;&gt;<br>         &lt;div className=&quot;headline&quot;&gt;<br>            &lt;span className=&quot;gold&quot;&gt;<br>          {<em>&lt;dynamic-variale&gt;</em>.goldTitle}<br>            &lt;/span&gt;<br>            &lt;span className=&quot;navy&quot;&gt;<br>          {<em>&lt;dynamic-variale&gt;</em>.navyTitle}<br>            &lt;/span&gt;<br>         &lt;/div&gt;</pre><pre>         {<em>&lt;dynamic-variale&gt;</em>.text}<br>         &lt;br /&gt;<br>      &lt;/div&gt;<br>   )<br>}</pre><pre>export default OurStory</pre><p>Whew, this aaaallllmost does it. So far, I’ve got my English and Spanish text saved in its own text data .js file, I’ve got my feature component set up to accept my dynamic variable that is being imported from the text data file, I’ve got my languageToggle set up and connected to my Redux store, and I’ve got an onChange function written to change the props of whichever component I am in to the language that has been selected…..but nothing is happening when I click back and forth between languages in my language toggle dropdown. What in the heck?</p><p>The last step here is that I need the page to reload whenever a new language is selected, in order to render the text in the language that I’m wanting to see. Because a change in props does not trigger a re-load by itself, I need to connect the component that I am trying to re-render to Redux as well, allowing it to force a reload with any change to props.</p><p>To the top of my feature component I add:</p><pre>import { connect } from &quot;react-redux&quot;;</pre><p>and to the bottom I add:</p><pre>const mapStateToProps = state =&gt; {<br>   return { size: state.size };<br>};</pre><p>and change my export to:</p><pre>export default connect(mapStateToProps)(Mentorship);</pre><p>and voila! Now when I select the language that I want to view from my language toggle dropdown menu, my site automatically re-renders with that text data of that language!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fblackrashdamselfly&amp;url=https%3A%2F%2Fgfycat.com%2Fblackrashdamselfly-aidy-bryant&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FBlackRashDamselfly-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="480" height="271" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f9ac336a64936c7a017c1832105a831/href">https://medium.com/media/3f9ac336a64936c7a017c1832105a831/href</a></iframe><p>The last little detail of note would be that this still leaves us having to select the language on every page of the website. This turned out to be an exceptionally easy solution, of storing the language selection not only in the state/props of our application, but also in the local storage of our browser. When we look back up at our languageToggle component, inside the onChange function we figured out that we could add a line of code to store the selection in the local storage as so:</p><pre>const handleChange = (event, data) =&gt; {<br>   localStorage.setItem(&quot;language&quot;, data.value);<br>   props.setLanguage(data.value);<br>};</pre><p>This keeps track of the language that we’ve selected as we move about through the site, and even if we close the site and re-open it later!</p><p>Hopefully this has helped to sort out how to go about adding a language toggle to your React application — or maybe even inspired you to do so….</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18e2497532e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/toggling-between-different-languages-in-your-react-website-18e2497532e1">Toggling between different languages in your React website</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clickable markers in a google-maps-react component]]></title>
            <link>https://medium.com/kirsten-werner/clickable-markers-in-a-google-maps-react-component-3e9a522e1fff?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e9a522e1fff</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[infowindow]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 00:06:41 GMT</pubDate>
            <atom:updated>2019-11-15T00:06:41.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBER52frYl2jmFBrlK0hEA.png" /></figure><p>So you’ve got a nifty Google Map imbedded in your React app (or if you don’t yet, go ahead and check out my blog on how to get that up and running — <a href="https://medium.com/kirsten-werner/integrating-google-maps-into-your-react-app-574d1faf3d79">Integrating Google Maps into your React app</a>). That’s super cool. But wouldn’t it be even cooler if your users could click on the markers that show up, and get some more detailed information about whatever the marker is marking?</p><p>The google-maps-react package that you installed to render the map in your app has a simple way to solve this! If you’ll remember, we have a Map component in our app that so far looks like this:</p><pre>import React from &quot;react&quot;;<br>import { withScriptjs, withGoogleMap, GoogleMap, Marker, InfoWindow } from &quot;react-google-maps&quot;;</pre><pre>const Map = withScriptjs(withGoogleMap((props) =&gt;{<br>   const recycleCenters = props.recycleCenters <br>  <br>   return (       <br>       &lt;GoogleMap zoom={4.5} center={ { lat:  39.6693, lng: -98.3476 } } /&gt;  <br>     <br>       {recycleCenters.map(center =&gt; (            <br>           &lt;Marker                 <br>              key={center.id}                 <br>              position={{                     <br>                 lat: center.latitude,                     <br>                 lng: center.longitude                 <br>              }}<br>           /&gt;        <br>        ))};</pre><pre>       &lt;/GoogleMap&gt;</pre><pre>}))</pre><pre>export default Map;</pre><p>First, notice that with the import from react-google-maps, we’ve included something called Infowindow. The Info window is exactly what we want to pop up when we click on a marker.</p><p>So what do we want to show in the info window? You can put anything you want in here! You can add pictures (think Redfin, when you click on a marker for a house for sale, and it pops up a picture of the house!), or any other information about the location that you have saved into your props that are being passed into the Map component.</p><p>In order for our app to know what marker has been clicked on, we’ll need to set the state like so —</p><pre>const [selectedCenter, setSelectedCenter] = useState(null);</pre><p>Then we, of course, need to add an event listener to our marker —</p><pre>&lt;Marker<br>   key={center.id}<br>   position={{<br>      lat: center.latitude,<br>      lng: center.longitude<br>   }}</pre><pre>   onClick={() =&gt; {<br>      setSelectedCenter(center);<br>   }}<br>/&gt;</pre><p>But we need to make sure that the info window shows up right on top of the marker, where we want it to. To do this, lets create the Infowindow that we imported from our react-google-maps package, and set the latitude and longitude</p><pre>{selectedCenter &amp;&amp; (<br>   &lt;InfoWindow<br>      onCloseClick={() =&gt; {<br>         setSelectedCenter(null);<br>      }}</pre><pre>      position={{<br>         lat: selectedCenter.latitude,<br>         lng: selectedCenter.longitude<br>      }}<br>   &gt;</pre><pre>   &lt;/InfoWindow&gt;<br>)}</pre><p>So good so far, now we have an empty window that pops up when we click on a marker! Filling in the info window with whatever you want is easy. For my RecycleIt! app, I wanted users to be able to see the name, address, phone number, and hours of operation for their selected center, and having passed that information to my Map component as props, I can format it like so —</p><pre>&lt;div&gt;<br>   &lt;h3&gt;{selectedCenter.name}&lt;/h3&gt;<br>   &lt;h5&gt;{selectedCenter.address}, {selectedCenter.city},{selectedCenter.state} {selectedCenter.zip_code}&lt;/h5&gt;<br>   &lt;h5&gt;{selectedCenter.phone_number}&lt;/h5&gt;<br>   &lt;p&gt;Hours of operation: {selectedCenter.hours}&lt;/p&gt;<br>&lt;/div&gt;</pre><p>Note that wrapping the display information in a &lt;div/&gt;, I am able to format with CSS — I could even add a className to the div, and set my CSS styling in my app.css file!</p><p>The last thing of importance when creating info windows that pop up when a user clicks on a marker, is that you don’t want that window to stay open forever. How annoying would it be if once you open one info window, it just stays….eventually your whole screen would be covered with overlapping info windows! React-google-maps gives us a handy method called useEffect that neatly handles this for us.</p><pre>useEffect(() =&gt; {<br>   const listener = e =&gt; {<br>      if (e.key === &quot;Escape&quot;) {<br>         setSelectedCenter(null);<br>      }<br>   };</pre><pre>   window.addEventListener(&quot;keydown&quot;, listener);</pre><pre>   return () =&gt; {<br>      window.removeEventListener(&quot;keydown&quot;, listener);<br>   };<br>}, <br>[]);</pre><p>And thats it! Now we have not only a working map, but one that displays markers for whatever locations our search returns, AND has info windows that open up when a user clicks on a marker!</p><p>You can check the official documentation for using info windows, including an example to see how to create a fully customized here:</p><p><a href="https://developers.google.com/maps/documentation/javascript/infowindows">Info Windows | Maps JavaScript API | Google Developers</a></p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e9a522e1fff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/clickable-markers-in-a-google-maps-react-component-3e9a522e1fff">Clickable markers in a google-maps-react component</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Google Maps into your React app]]></title>
            <link>https://medium.com/kirsten-werner/integrating-google-maps-into-your-react-app-574d1faf3d79?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/574d1faf3d79</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 11 Nov 2019 07:31:23 GMT</pubDate>
            <atom:updated>2019-11-14T22:47:31.656Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ctzpD3cSg75zmKRf8zFyBA.png" /></figure><p>While creating an app to allow users to locate recycle centers that will accept whichever specific material they are trying to dispose of, it occurred to me that it would be a LOT more useful if the user could actually see where the recycle centers are on a map…..enter Google Maps! But how in the world does one go about integrating a map into a React application?</p><p>First things first, you’ll need to request an API key from Google.</p><p><a href="https://developers.google.com/maps/documentation/javascript/tutorial?source=post_page-----9694a475f00a----------------------">Overview | Maps JavaScript API | Google Developers</a></p><p>Google’s documentation is very thorough, including directions on getting the API key and simple tutorials to walk you through the process of implementing a map in a simple plain javascript project.</p><p>Next, you’ll need to install the google-maps-react package in order for your project to generate a map on your webpage, via</p><pre>npm install --s google-maps-react</pre><p>You can check out the official documentation about the google-maps-react package here</p><p><a href="https://www.npmjs.com/package/google-map-react?source=post_page-----9694a475f00a----------------------">google-map-react</a></p><p>Now comes the fun part, of getting this stuff to actually display. Since I am specifically using the map to display the location of recycle centers returned from the user-generated search, I created a container file called RecycleCentersMapContainer.js. This container is where you will specify the size of your map, utilize your Google-Maps-Javascript API, and pass in the props that you want displayed on the map into the Map object, as shown below:</p><pre>import React from &quot;react&quot;;</pre><pre>import Map from &quot;../components/maps/RecycleCentersMap&quot;;</pre><pre>const KEY = process.env.REACT_APP_GOOGLE_API_KEY;</pre><pre>export default class RecycleCenterssMapContainer extends React.Component {</pre><pre>  render() {</pre><pre>     return (</pre><pre>        &lt;div className=&quot;map-container&quot;&gt;</pre><pre>        &lt;Map</pre><pre>           recycleCenters={this.props.recycleCenters}</pre><pre>           googleMapURL={`https://maps.googleapis.com/maps/api/js?   key=${KEY}&amp;v=3.exp&amp;libraries=geometry,drawing,places`}</pre><pre>           loadingElement={&lt;div style={{ height: `100%` }} /&gt;}</pre><pre>           containerElement={&lt;div style={{ height: `600px`, width: `100%` }} /&gt;}</pre><pre>           mapElement={&lt;div style={{ height: `100%` }} /&gt;}</pre><pre>        /&gt;</pre><pre>       &lt;/div&gt;</pre><pre>     );</pre><pre>  }</pre><pre>}</pre><p><em>I’ve heard horror stories of having Google API keys being stolen off of public Github repositories by a malicious bots, and innocent developers all of a sudden having literally thousands of dollars charged to the back account linked to their Google account. So under no circumstance ever put your key in a form where someone can access it through your public repos!!! Mine here is hidden in a .env file, which is then specified in my gitignore file, and accessed using the dotenv package.</em></p><p>But where does the Map component come from? The RecycleCentersMapContainer imports the Map from the RecycleCentersMap component.</p><pre>import React from &quot;react&quot;;</pre><pre>import { withScriptjs, withGoogleMap, GoogleMap, Marker, InfoWindow } from &quot;react-google-maps&quot;;</pre><pre>const Map = withScriptjs(withGoogleMap((props) =&gt;{</pre><pre>const recycleCenters = props.recycleCenters</pre><pre>   return (</pre><pre>       &lt;GoogleMap zoom={4.5} center={ { lat:  39.6693, lng: -98.3476 } } /&gt;</pre><pre>       {recycleCenters.map(center =&gt; (</pre><pre>            &lt;Marker</pre><pre>                 key={center.id}</pre><pre>                 position={{</pre><pre>                     lat: center.latitude,</pre><pre>                     lng: center.longitude</pre><pre>                 }}<br>            /&gt;</pre><pre>        ))};<br>        &lt;/GoogleMap&gt;<br>}))</pre><pre>export default Map;</pre><p>Inside the opening GoogleMap tag, you must set an initial zoom, and tell the map where you would like it to be centered via latitude and longitude. The zoom works in the way that the closer you get to 1, the farther out you are zoomed. In order to show the entire country, I chose a zoom that is fairly low, 4.5. Then to center the map so that the US would show up properly, I chose a small town called Ionia, Kansas to center.</p><p>As you can see in the above code, I use the JS function “map” to map through the recycle center data that was previously pulled from my external API and passed as props into my Map component, to create the markers that show up on the google map. You can pass in whatever information you want, from an external or internal API, or even coded directly on the front end of your application. Please don’t get confused by the multiple uses of the word “map”!</p><p>Awesome, I now have a working map with markers for each of the recycle centers returned in my search! Wouldn’t it be cool if I could click on the markers to get more information about each individual center? Find out how to do that in my next blog, Clickable markers in a react-google-maps component.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=574d1faf3d79" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/integrating-google-maps-into-your-react-app-574d1faf3d79">Integrating Google Maps into your React app</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[9 Reasons to learn PHP in 2019.]]></title>
            <link>https://medium.com/kirsten-werner/9-reasons-to-learn-php-in-2019-31d62997aaf8?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/31d62997aaf8</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Wed, 06 Nov 2019 00:53:28 GMT</pubDate>
            <atom:updated>2019-11-06T00:53:28.236Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vl8UZ2TWezp_Nxo1.jpg" /></figure><p>What is PHP? PHP is a programming language made for web development, that is built up from C. Originally released in 1994, PHP was initially intended to be used strictly as a light-weight scripting tool, rather than a full fledged language. That’s why the acronym stood for “Personal Home Page” — but as PHP grew and took on a life of its own, though open source contributions, PHP can now be used for nearly anything that any other language can, making the original acronym sound rather limiting. PHP now is regarded as standing for “PHP: Hypertext Preprocessor” (This is referred to as a recursive acronym, with an admittedly nerdy affection).</p><p>PHP is mostly used server-side, and basically anything you want to do on a web server, you can do with PHP. WordPress, arguably the biggest blog platform — claiming to power 30% of the internet! — is built on PHP. Countless software-as-a-service applications are built on PHP. PHP is perfectly suited for server-side scripting and command line scripting.</p><p>Certainly, PHP is a bit ugly (honestly — opening and closing tags look like the this?!).</p><pre>&lt;?php </pre><pre>  // some code here</pre><pre>?&gt;</pre><p>And PHP is an old language — up there with oldest. Is it still worth it to learn PHP in 2019? Some argue that PHP is going out of style. Or that it is a dying language. Why should I spend my time and energy focusing on this?</p><p>I’ll start with the most compelling reason:</p><ol><li><strong>PHP is everywhere the web is, and has a massive community.</strong></li></ol><p>This wealth of community means that easy and efficient ways to do nearly everything have already been figured out by someone. You can build content-loaded websites that are convenient and easy to update, meaning that even the not-necessarily tech-y staff or web admins can easily make changes and manage content.</p><p>Some of the most hugely popular content management systems are written with PHP: Joomla, Drupal, Magento, Expression Engine, vBulletin, MediaWiki, to name a few. And there’s even more frameworks to work with, including Symhony, Zend, Laravel, Aura, Yii, etc.</p><p>And as I searched, I came up with a lot more reasons…..</p><p>2. <strong>Because of its immense community, PHP has a massive amount of libraries and extensions.</strong></p><p>This means that you can easily handle tasks like creating blogging pages, shopping carts, error displaying, and code debugging — because someone else has already done it!</p><p>3. <strong>PHP does HTML rendering and programming better than almost any other language.</strong></p><p>You can literally change a .html file to a .php file, add the opening and closing tags, and it will work!</p><p>4. <strong>With PHP you can quickly and simply deploy applications, and its scaling potential is incredible.</strong></p><p>Skeptical about PHP’s scalability? Think about Wikipedia and Facebook….</p><p>5. <strong>The documentation available for PHP is extremely thorough and accessible.</strong></p><p>This makes PHP approachable for everyone from beginners to experts, and everyone in between.</p><p>6. <strong>First class debugging with Xdebug.</strong></p><p>7. <strong>PHP supports both object-oriented and functional programming paradigms.</strong></p><p>Hello, versatile!</p><p>8. <strong>Because PHP has been used for so long, there are a LOT of <em>expert </em>experts.</strong></p><p>Whatever you’re working on, you’ll always be able to find someone with years and years of experience to help you out if you’ve gotten yourself really stuck. This in and of itself could lead to significantly lower development costs!</p><p>9. <strong>PHP has fully modernized.</strong></p><p>Although it started as a simple scripting tool with no intention of becoming a full-fledged language, PHP has since grown into a fully dynamic language that can compete with any of the others out there. PHP is both flexible and strict — allowing the programmer to decide exactly how to use it!</p><p>With all of these reasons to use PHP, why has it still got the reputation of a “dying language”? Personally I think this comes as the flip-side of it being so easy to use — exactly because it’s so easy and accessible, there is a lot of bad code written by amateur programmers. But don’t blame the language — For all of the bad code, the size on the community allows for ample direction to sort it out!</p><p>So yes, in my opinion, it is still extremely valuable to learn PHP in 2019. It is a language that has not only stuck around, but grown and adapted for 25 years, and shows no signs of stopping.</p><p>And with that, I’ll leave you with a beautiful quote from Quora user Vaibhav Kaushal:</p><blockquote>Code is poetry. And poems are written in all languages. You need the rhythm and emotion more that the grammar and foresight; if you have the rhythm and the emotion, you can write poems in all languages of this world and beyond.</blockquote><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31d62997aaf8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/9-reasons-to-learn-php-in-2019-31d62997aaf8">9 Reasons to learn PHP in 2019.</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using a React form to send information directly to your email]]></title>
            <link>https://medium.com/kirsten-werner/using-a-react-form-to-send-information-directly-to-your-email-2c9666f0d63a?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c9666f0d63a</guid>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 28 Oct 2019 04:31:41 GMT</pubDate>
            <atom:updated>2019-10-28T18:24:06.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*RVYM9asNiCZZfyZZ" /></figure><p>When designing my personal website, it occurred to me that it would be really cool if I people could contact me directly from my page, without having to go through the trouble of copying my email address, opening their own email server, pasting my address, and THEN getting whatever they wanted to say off of their chest.</p><p>So what obstacles does this present? For one, I didn’t want to create a backend just for email purposes, and I also don’t want to any personal information saved in my code, like my own email server API! The way that I found to get around this, is to use an intermediary service called EmailJS. According to the <a href="https://www.emailjs.com/docs/introduction/how-does-emailjs-work/">EmailJS docs</a>, “EmailJS helps sending emails using client side technologies only. No server is required — just connect EmailJS to one of the supported email services, create an email template, and use our Javascript library to trigger an email.”</p><p>Creating an account with EmailJS is free, and allows 200 emails to be sent a month - which I imagine to be WAY more than any contact I will be getting from my personal website. You connect your account by hitting the “Connect account” button, selecting the email provider of your choosing, and then pressing the “Add Service” button to complete the process. The selected email service will then be marked as the default. You can connect either a personal email service if you want to connect to your own email address, or you can add a transactional email service from something like Mailgun or Mandril to serve as the email server.</p><p>Once you’ve connected the email server, the next step is to create a template for what the email sent will look like. To do this, open the Email Templates page from the dashboard, click on “Create new template”, and fill out the template properties. The really cool part here, is that you can create dynamic properties that, paired with the magic of React state, can grab information from the form displayed on your React web page (what the user has entered) and populate your email template!!</p><p>Okay, Okay, getting ahead of myself. Let’s back up a little bit, and switch around to the React side of this whole ordeal. In my form component, we need to do what we just talked about — write the code for the content form, including state and event handler to set the state with whatever someone fills it out with.</p><pre>export default class extends React.Component {<br>  constructor(props) {<br>    super(props);</pre><pre>this.state = {<br>      name: &quot;&quot;,<br>      email: &quot;&quot;,<br>      feedback: &quot;&quot;,<br>    };<br>  }</pre><pre>handleInputChange(event) {<br>    event.preventDefault();<br>    const target = event.target;<br>    const name = target.name;<br>    const value = target.value;</pre><pre>this.setState({ [name]: value });<br>  }</pre><p>Then I write the render function to display the form that I want my users to see, making sure that my event handlers are set to my different input text fields like so:</p><pre>render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;form<br>          className=&quot;ui form&quot;<br>          id={this.props.id}<br>          name={this.props.name}<br>          method={this.props.method}<br>          action={this.props.action}<br>        &gt;<br>          &lt;textarea<br>            id=&quot;name&quot;<br>            name=&quot;name&quot;<br>            onChange={this.handleInputChange.bind(this)}<br>            placeholder=&quot;your name&quot;<br>            required<br>            value={this.state.name}<br>            style={{ width: &quot;100%&quot; }}<br>            rows={1}<br>          /&gt;<br>          &lt;br /&gt;<br>          &lt;textarea<br>            id=&quot;email&quot;<br>            name=&quot;email&quot;<br>            onChange={this.handleInputChange.bind(this)}<br>            placeholder=&quot;your email address&quot;<br>            required<br>            value={this.state.email}<br>            error={this.state.errors.email}<br>            style={{ width: &quot;100%&quot; }}<br>            rows={1}<br>          /&gt;<br>          &lt;br /&gt;<br>          &lt;textarea<br>            id=&quot;feedback&quot;<br>            name=&quot;feedback&quot;<br>            onChange={this.handleInputChange.bind(this)}<br>            placeholder=&quot;what would you like to chat about?&quot;<br>            required<br>            value={this.state.feedback}<br>            style={{ width: &quot;100%&quot;, height: &quot;250px&quot; }}<br>          /&gt;<br>          &lt;br /&gt;<br>          &lt;input<br>            type=&quot;button&quot;<br>            value=&quot;Send&quot;<br>            className=&quot;ui button&quot;<br>            style={{<br>              fontFamily: &quot;Amatic SC&quot;,<br>              fontSize: &quot;20px&quot;,<br>              color: &quot;blue&quot;<br>            }}<br>            onClick={this.sendMessage.bind(this)}<br>          /&gt;<br>        &lt;/form&gt;<br>      &lt;/div&gt;<br>    );<br>  };</pre><p>Okay, great. Now for connecting my form to my EmailJS. As I used create-react-app to start my project file tree, I already have a public/index.html file. In this file, I added script for EmailJS directly into the document head, like so:</p><pre>&lt;script type=&quot;text/javascript&quot;    src=&quot;https://cdn.jsdelivr.net/npm/emailjs-com@2.4.0/dist/email.min.js&quot;&gt;<br>    &lt;script type=&quot;text/javascript&quot;&gt;<br>       (function(){<br>          emailjs.init(&quot;%REACT_APP_EMAILJS_USERID%&quot;);<br>       })();<br>    &lt;/script&gt;</pre><p>You also can instal EmailJS as an npm package, using:</p><pre>$ npm install emailjs-com --save</pre><p>Finally, in my form component, I added a sendMessage() function. This function uses the EmailJS send() function (described in the documentation <a href="https://www.emailjs.com/docs/sdk/send/">here</a>) that includes the parameters that I am going to set in my email template — <strong>from_name</strong>, <strong>to_name</strong>, and <strong>feedback</strong>.</p><pre>sendMessage(event) {<br>    event.preventDefault();</pre><pre>if (!this.validateMail()) {<br>      return;<br>    }</pre><pre>const templateParams = {<br>      from_name: this.state.name + &quot; (&quot; + this.state.email + &quot;)&quot;,<br>      to_name: <em>{wherever you are sending the email}</em>,<br>      feedback: this.state.feedback<br>    };</pre><pre>emailjs<br>      .send(&quot;gmail&quot;, &quot;portfoliositecontact&quot;, templateParams, <em>{id given from your EmailJS template}</em>)<br>      .then(<br>        function(response) {<br>          toast.success(&quot;Your message has successfully sent!&quot;, {<br>            position: toast.POSITION.BOTTOM_CENTER<br>          });<br>          console.log(&quot;SUCCESS!&quot;, response.status, response.text);<br>        },<br>        function(err) {<br>          toast.error(&quot;Your message was not able to be sent&quot;);<br>        }<br>      );</pre><pre>this.setState({<br>      name: &quot;&quot;,<br>      email: &quot;&quot;,<br>      feedback: &quot;&quot;<br>    });<br>  }</pre><p>Finally, now that I have my form and state set up on the React side, I can go <em>back</em> to the EmailJS email template that I was talking about before, and dynamically set the properties to accept whatever has been stored in the state of my React form. Properties wrapped in double curly braces ({{ }}) will fill in dynamically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvuPcegMn2H_WeND0elpbg.png" /></figure><p>And bam! Your React app can now send information entered in a contact form directly to your personal email account!</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c9666f0d63a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/using-a-react-form-to-send-information-directly-to-your-email-2c9666f0d63a">Using a React form to send information directly to your email</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Displaying notifications on a React app form]]></title>
            <link>https://medium.com/kirsten-werner/displaying-notifications-on-a-react-app-form-bfafe2d3b33e?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfafe2d3b33e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[toast]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 21 Oct 2019 04:08:09 GMT</pubDate>
            <atom:updated>2019-10-21T04:08:09.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FOvfJzycaPXdse2NZcxMDg.png" /></figure><p>Having a nice, working form in your React app is a great way to gather input from the user to manipulate or store — but it can be a little bit confusing *for* the user when they enter their information into your form, click the submit button, and then…..what? The form clears (or doesn’t, depending on what you’ve set up), and the user is left to cross their fingers and hope that something has been happened behind the scenes. Wouldn’t it be awesome if you could somehow give your user some immediate feedback to let them know that the form they have just filled out has worked how it’s intended to?</p><p>Enter notifications! There are numerous packages designed to display notifications — also called toasts — within your React app, but the one that I have found to be both simple enough to not give you a headache to utilize AND dynamic enough to allow some neat customization is React-Toastify.</p><p>React-Toastify has a ton of features that make it easy and attractive to use. For one, it’s seriously easy to setup. In your terminal simply enter</p><pre>npm install --save react-toastify</pre><p>After you’ve got the package installed on your project, there are two important things to import anywhere in your app that you intend to have toasts show up:</p><pre>import { ToastContainer, toast } from &#39;react-toastify&#39;; </pre><p>The toast container should be rendered only one time in your application tree. For example, if you have got a few separate components that are all being rendered to create the full page view of your app (like a navigation bar, body, and footer) but do not want your toasts to end up being hidden behind the view of the header, rendering the ToastContainer in your application root would allow it to be visible *above* the components that make up your shoe view.</p><pre>import { ToastContainer, toast } from &#39;react-toastify&#39;;</pre><pre>function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;div&gt;<br>        &lt;ToastContainer /&gt;<br>        &lt;NavBar /&gt;<br>        &lt;Route exact path=&#39;/&#39; component={ Home } /&gt;<br>        &lt;Footer /&gt;<br>      &lt;/div&gt;<br>    &lt;/Router&gt;<br>  );<br>}</pre><pre>export default App;</pre><p>As long as you configure your ToastContainer before it is rendered, its possible to customize your toasts with a variety of props.</p><pre>toast.configure({</pre><pre>     autoClose<strong>:</strong> 8000,</pre><pre>     draggable<strong>:</strong> false,</pre><pre><em>     //etc you get the idea</em></pre><pre>});</pre><p>Once you have your container set up, you can start to use toasts wherever you like. In a recent app that I made, I have a form which allows the user to send an email directly from the page to my personal email address. The form has text boxes for the user to enter their name, their email address, and whatever content they would like to send to me — because I don’t want to receive emails that I either don’t know from whom they were written or have no way to respond to, I’ve included some validations to make sure that a valid name, email address, and that the content of the email is not empty. Applying React-Toastify to show notifications of an error in form information looks like so:</p><pre>validateMail () {<br>    let errors = {}<br>    let formIsValid = true</pre><pre>if (!this.state.name || this.state.name.length &lt; 3) {<br>      errors.name = &quot;I&#39;d love it if your name was at least 3 characters long...&quot;<br>      toast.error(`${errors.name}`, {<br>        position: toast.POSITION.TOP_LEFT      });<br>      formIsValid = false<br>    }</pre><pre>if (!this.state.feedback || this.state.feedback.length &lt; 10) {<br>      errors.feedback = `C&#39;mon, the body of your message should say SOMEthing!`<br>      toast.error(`${errors.feedback}`);<br>      formIsValid = false<br>    }</pre><pre>if (!this.state.email || this.state.email.length &lt; 3) {<br>      errors.email_1 = &#39;Your email address has got to have at least 3 characters.&#39;<br>      toast.error(`${errors.email_1}`);<br>      formIsValid = false<br>    }</pre><pre>let pattern = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/</pre><pre>if (!pattern.test(this.state.email)) {<br>      errors.email_2 = &#39;Email addresses need an @ and a .com&#39;<br>      toast.error(`${errors.email_2}`);<br>      formIsValid = false<br>    }</pre><pre>this.setState({<br>      errors: errors<br>    })<br>}</pre><p>Any props that are not defined in the ToastContainer configuration will resort to their default, and any props that are defined in the body of a specific toast will override the ToastContainer prop. You can see an example of how a prop might be defined within the specific toast in the first if statement of the above code.</p><p>To see a list of all of the props that React-Toastify readily allows you to define in either your ToastContainer, or in your specific toasts, please reference the official <a href="https://www.npmjs.com/package/react-toastify#toastcontainer">documentation</a>.</p><p>This has been a pretty simple explanation of how to install and very easily set up and customize toasts for your app using React-Toastify. There are so many more ways that you can customize your toasts to really convey what you want to your user — check out the (much more detailed) official documentation <a href="https://www.npmjs.com/package/react-toastify#toastcontainer">here</a>.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfafe2d3b33e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/displaying-notifications-on-a-react-app-form-bfafe2d3b33e">Displaying notifications on a React app form</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Controlled forms vs. Uncontrolled forms in React]]></title>
            <link>https://medium.com/kirsten-werner/controlled-forms-vs-uncontrolled-forms-in-react-34938d7834a1?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/34938d7834a1</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Thu, 01 Aug 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-10-09T00:06:31.430Z</atom:updated>
            <content:encoded><![CDATA[<p>React has two ways of handling forms: controlled and uncontrolled. But what does that mean? And when would you want to use one or the other? Let’s take a look.</p><h3>Uncontrolled Forms</h3><p>Uncontrolled forms are the simplest way to handle form input in React. Inputs here are handled like traditional HTML inputs, where the form data is being handled by the DOM itself, and there is no change to state. The input data only becomes available when the data is submitted, and can be accessed by a ref and a callback function. With uncontrolled form input, what you submit is what you get.</p><p>For example:</p><p>Using uncontrolled form input is most useful when the form you are designing is very simple and has no reason to be accessible before a submit.</p><h3>Controlled Forms</h3><p>When you are creating a form that is more complex, or needs to have some sort of dynamic element, controlled forms are more your cup of tea! For example, if you have a password field and you want an error to display until the required conditions of the password are met, you will need the form input to be stored and available <em>while</em> the user is typing, not simply after the user clicks submit.</p><p>Controlled forms store the current input value as a prop, and with every change to the input field (each key stroke), a callback function is handling the change and updating the state to the current input value. Controlled forms allow the form containing component to always have access to the current input value, without having to call for it explicitly! This can be useful for in-place input validations and enforcing data input format, amongst other things.</p><p>A controlled form might look more like this:</p><h3>When to use Controlled vs. Uncontrolled</h3><p>Uncontrolled forms are useful when the form and input data are very basic, with minimal features. The main con to using uncontrolled forms is that there is not much extra functionality that can be attached to your form.</p><p>Controlled forms are the way to go if you need functionality such as validation or instant user feedback. Writing controlled forms is more complicated, so more code will be necessary, and updating large forms may be a bit tedious.</p><p>Hopefully this helps clear up some beginner confusion about when/where/and why to use controlled vs. uncontrolled forms.</p><p>Happy Coding!</p><p><em>Originally published at </em><a href="https://kirstenwerner.github.io/controlled_forms_vs_uncontrolled_forms_in_react"><em>https://kirstenwerner.github.io</em></a><em> on August 1, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34938d7834a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/controlled-forms-vs-uncontrolled-forms-in-react-34938d7834a1">Controlled forms vs. Uncontrolled forms in React</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Semantic-ui-react to style your app]]></title>
            <link>https://medium.com/kirsten-werner/using-semantic-ui-react-to-style-your-app-765ace1d3b8?source=rss-76a8a8384346------2</link>
            <guid isPermaLink="false">https://medium.com/p/765ace1d3b8</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kirsten Werner]]></dc:creator>
            <pubDate>Mon, 29 Jul 2019 00:00:00 GMT</pubDate>
            <atom:updated>2019-10-08T01:45:16.607Z</atom:updated>
            <content:encoded><![CDATA[<p>Coming into my fifth and final portfolio project for my online software engineering bootcamp, I knew that submitting an app with zero styling would be unacceptable. I looked at some of my options, including styling completely from scratch by writing all of the CSS myself (and quickly decided I do NOT have the CSS expertise nor the stylistic eye for this to be very reasonable), bootstrap, and semantic-ui. I found that semantic-ui had really accessible and thorough and documentation, and some pretty cool features to choose from, so chose that route.</p><p>First things first, to add styling to your react app with semantic-ui, you need to install the package to the app that you want to style. This is incredibly easy — in your terminal, navigate to the file for your project, and enter the line</p><p>(alternatively, you could use ‘yarn’, rather than ‘npm’, if you are more comfortable with that notation)</p><p>The next step <em>(and this one is important!)</em>, is to enter a line of code in your index.html file that allows your app to access the semantic-ui CSS styling sheet. I floundered for embarrassingly long after adding the necessary tags around my app and not seeing ANY change in the styling of my app in browser, before realizing that I could import and tag all I wanted and never see ANYTHING without access to the packages built in CSS. There are certainly some variations you can make to this line to fit your specific needs, but the simple line I found to allow the access I needed was as such:</p><p>Once you have semantic-ui installed, and the CSS stylesheet referenced, you are able to start playing around with all sorts of cool style features! You can format buttons, forms, containers, and cards — among many many other things.</p><p>I chose to start my styling by creating a navigation bar that would allow users to navigate around my single page web app by clicking on buttons that would appear at the top of the page no matter what else was rendered on the page. This task is easily handled by semantic-ui. First, you need to import whichever feature (which has corresponding tags) you are intending to use from the semantic-ui library. For me, this meant at the top of my NavBar.js file, I needed to add this line:</p><p>and then incapsulate the code that I want to describe my buttons with the appropriate semantic-ui tags, like so:</p><p>*note, my semantic-ui ‘Button’s are also encapsulated in NavLink tags in order to use the react-routed-dom to allow my app to use restful routing.</p><p>Next, I wanted to simply enclose sections of my app that contained text in semantic-ui containers, in order to keep the layout of all of the pages neat and consistent (and to avoid text running all the way to the edge of the browser window). This was immensely simple, by importing { Container } from semantic-ui-react, and then wrapping the &lt;div&gt;&lt;/div&gt; tags in which my text was rendered inside of tags.</p><p>Finally, for the purposes of my app, the last thing I wanted to style was to create cards to display information on a show page in a neatly organized and consistently stylized way. Semantic-ui has an immense library of card options, allowing one to control nearly every aspect of the card presentation, simply by wrapping the rendered JSX in descriptive tags specifying what you would like the card to do. You can group cards, make them dynamically resize or reorganize depending on the size of the browser window, contain images, links, and buttons, among oh so much more. For my app, I wrapped my cards with tags to organize them into columns with evenly structured cards by adding this code:</p><p>For more detail about how to style your app using Semantic-ui, visit the documentation at <a href="https://semantic-ui.com/">https://semantic-ui.com/</a></p><p>Happy coding!</p><p><em>Originally published at </em><a href="https://kirstenwerner.github.io/using_semantic-ui-react_to_style_your_app"><em>https://kirstenwerner.github.io</em></a><em> on July 29, 2019.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=765ace1d3b8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kirsten-werner/using-semantic-ui-react-to-style-your-app-765ace1d3b8">Using Semantic-ui-react to style your app</a> was originally published in <a href="https://medium.com/kirsten-werner">Kirsten Werner</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>