<?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 Mark Battersby on Medium]]></title>
        <description><![CDATA[Stories by Mark Battersby on Medium]]></description>
        <link>https://medium.com/@markalfred?source=rss-32d791ed99a5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_ZZ48ShOZ2EkTpTjktA6Gw.jpeg</url>
            <title>Stories by Mark Battersby on Medium</title>
            <link>https://medium.com/@markalfred?source=rss-32d791ed99a5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:46:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@markalfred/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[So you want to add a select box?]]></title>
            <link>https://medium.com/@markalfred/so-you-want-to-add-a-select-box-d0c789fda6d9?source=rss-32d791ed99a5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0c789fda6d9</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[fatigue]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[satire]]></category>
            <dc:creator><![CDATA[Mark Battersby]]></dc:creator>
            <pubDate>Thu, 20 Oct 2016 13:32:48 GMT</pubDate>
            <atom:updated>2016-10-20T13:33:13.639Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ruminations on the React / Redux state of things.</h4><p>React and Redux are simple, elegant, and easy to reason about. Let’s jump right in.</p><p>Write a function to call an API and get your potential options.<br>Add a type constant to use in your reducer and action.<br>Import the type into your reducer file.<br>Add a reducer to save the potential options.</p><p>Import the type into your actions file.<br>Add an action generator to pass the options to the reducer.</p><p>Map the options that are now in state to the props of your container.<br>Add the prop to the container’s PropTypes to ensure it’s very safe, via runtime errors.<br>Promptly ignore these errors.</p><p>Import your component into the container.<br>Pass the potential options prop to the component.<br>Add a type constant for the currently selected option to use in the reducer and action.<br>Import the type into your reducer file.<br>Add a reducer to save the currently selected option.<br>Import the type into your actions file.<br>Create an action generator to set the currently selected option.</p><p>Map the state of the currently selected option to the props of your container.<br>Add the prop to the PropTypes of the container for the currently selected option.<br>Add the currently selected option to the props passed to the component.</p><p>Import the API call into your container.<br>Import the action to update the current potential selections.<br>Add the API call to the container’s appropriate lifecycle method.<br>Chain the action which saves your potential options to the return of the API call.</p><p>Import the action to update the currently selected option into your container as your on-change handler.<br>Bonus: Create a function that validates the selected option and calls your option setter action only if it passes validations.<br>Double bonus: Forget to add <strong>this.validator = this.validator.bind(this)</strong> to your container’s <strong>constructor()</strong> and go fuck yourself.</p><p>Pass the on-change handler to your component.<br>Add the selectable options structure to your component PropTypes.<br>Add the currently-selected option to your component PropTypes.<br>Add the change handler to your component PropTypes.</p><p>Add the select box.<br>Pass the currently selected option.<br>Pass the change handler.<br>Map over the potential options and render each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*At76z0b930FeeEUyTPv-zQ.png" /><figcaption>Elegance.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0c789fda6d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>