<?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 David Madi on Medium]]></title>
        <description><![CDATA[Stories by David Madi on Medium]]></description>
        <link>https://medium.com/@davidmadi?source=rss-7654afe0fc36------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DdxUGemfY1K8hh9J.jpg</url>
            <title>Stories by David Madi on Medium</title>
            <link>https://medium.com/@davidmadi?source=rss-7654afe0fc36------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:52:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davidmadi/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 React – No setup, no basics, no libraries, no concepts, no lecture, no philosophy, simple…]]></title>
            <link>https://medium.com/@davidmadi/simple-react-9b2f2eabe9ab?source=rss-7654afe0fc36------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b2f2eabe9ab</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[introduction]]></category>
            <category><![CDATA[5min]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[simple]]></category>
            <dc:creator><![CDATA[David Madi]]></dc:creator>
            <pubDate>Sat, 30 Dec 2017 21:05:08 GMT</pubDate>
            <atom:updated>2017-12-31T04:01:44.107Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple React – No setup, no basics, no libraries, no concepts, no lecture, no philosophy, simple react.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLg5kRitrq85AOnHvRgxxA.jpeg" /></figure><p>Quick introduction.</p><p>This is for you, a programmer who just want to know how react works, no setup, no basics, no other libraries, no other concepts, no lecture, no philosophy, simple react.</p><p>I believe you are going to spend 5 minutes reading this article, and after that, realising why react is so powerful.</p><p>Starting — The Project.</p><p>The project I&#39;m based on is an object with other objects as childs, a simple list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*okzAQrwz01omjxvgHIow3w.png" /></figure><p>This is the code used in the index.js, the main &quot;class&quot; that is used to render the first tag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*8kIjOE55Eh9fFZSZP5XxkQ.png" /></figure><p>See, I&#39;m rendering the &quot;Page1&quot; component, and the page is going to create the list of objects to render inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*pU6HxfpyRETKrMO97wOw3Q.png" /></figure><p>Now, the code of the Page1.</p><p>1 - The constructor creates an empty list, and the render, renders nothing. But after we click in publish, the list is filled with made up values.</p><p>2 - The setState function, merges the properties of the input json, and renders the the list of items.</p><h4>Let&#39;s see what&#39;s inside the Item1 component.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKBaz_-5o5eNrr0a0WLzEQ.png" /></figure><p>The Item1 component is very simple.</p><p>1 — The constructor receives the properties from the page.</p><p>2 — Every time it renders, we show the second of the clock (just to prove it&#39;s rendering)</p><p>3 — Call the function of the button.</p><p>4 — When I click, it adds 1 to the counter and re-render. (That&#39;s the spot where we can call ajax, fetch or anything to persist the data.</p><h3>Let&#39;s see it working.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*uFOeHTiNDE8GgMM5zM6tGw.gif" /></figure><h4>That&#39;s it for simple react. But if you want to know about redux, keep reading…</h4><h3>Now, let&#39;s check-out redux.</h3><p>I&#39;m rendering the Page2 component on the index, as usual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*LUKMdZ_dcqesomUZt7pNjQ.png" /></figure><p>Now, there are few steps inside the Page2 component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wOlUmki2GQ55XGMiFKK4Tw.png" /></figure><p>1 — The constructor creates an empty list.</p><p>2 — I created a &quot;redux store object&quot; to store the state. It requires a reducer function to operate it. This function receives the current state (stored previously) and the action (what ever you want when calling the dispatch)</p><p>3 — After render the page I subscribe the Page for every change in the redux store. (Inside it, I get the last state and re-render everything, just as simple react)</p><p>4 — On the first bind, I dispatch an action with a name and a list.</p><p>5 — The reducer function must return the new state, to be compared with the previous and IF changed, rendered.</p><p>6 — Calling the button to publish.</p><p>The Item2 component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*gNPf7KP3OO_xdQ9P2tKgXw.png" /></figure><p>It receives the store as property and calls the dispatch with itself as a parameter.</p><p>That&#39;s it.</p><h4>Let&#39;s see it working</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*a0INH_ko6T-NzhLha3H0cw.gif" /></figure><p>See the difference?</p><p>Now I&#39;m calling the setState of the page, not the item, that&#39;s why it is rendering all of them.</p><p>Even if I doesn&#39;t change the item, it renders. I don&#39;t believe it worths the effort to control it.</p><p>That&#39;s all for this article. Of course it doesn&#39;t explains all about react, and there are a few related things we should think about, like immutable, fetch, promise and everything else.</p><p>If you want to download the project, this is the link: <a href="https://github.com/davidmadi/simplereact">https://github.com/davidmadi/simplereact</a></p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b2f2eabe9ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>