<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adeyemi Simeon</title>
    <description>The latest articles on DEV Community by Adeyemi Simeon (@boasbabs).</description>
    <link>https://dev.to/boasbabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F175068%2F0d6aed74-3199-4e1f-b1c4-c6e170ee4a31.jpg</url>
      <title>DEV Community: Adeyemi Simeon</title>
      <link>https://dev.to/boasbabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/boasbabs"/>
    <language>en</language>
    <item>
      <title>Yup Schema for Nigeria Phone Mobile Number</title>
      <dc:creator>Adeyemi Simeon</dc:creator>
      <pubDate>Sat, 09 Oct 2021 09:08:19 +0000</pubDate>
      <link>https://dev.to/boasbabs/yup-schema-for-nigeria-phone-mobile-number-2mma</link>
      <guid>https://dev.to/boasbabs/yup-schema-for-nigeria-phone-mobile-number-2mma</guid>
      <description>&lt;p&gt;I was trying out Regex to validate Nigerian mobile numbers without the country code (+234). &lt;br&gt;
Here is what I came up with. &lt;br&gt;
Not sure if it is perfect though. Any other ideas?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;yup&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;yup&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/*
Regex to match Nigeria mobile number with the country code +234
It matches:
08053303925
09055303925
08145327190
*/&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;phoneRegExp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;([&lt;/span&gt;&lt;span class="sr"&gt;0&lt;/span&gt;&lt;span class="se"&gt;]{1})[&lt;/span&gt;&lt;span class="sr"&gt;0-9&lt;/span&gt;&lt;span class="se"&gt;]{10}&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;

&lt;span class="nx"&gt;cconst&lt;/span&gt; &lt;span class="nx"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;yup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;yup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;phoneRegex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invalid phone number.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>javascript</category>
      <category>yup</category>
      <category>regex</category>
    </item>
    <item>
      <title>The Analogy of State Management in React</title>
      <dc:creator>Adeyemi Simeon</dc:creator>
      <pubDate>Tue, 03 Dec 2019 21:25:58 +0000</pubDate>
      <link>https://dev.to/boasbabs/the-analogy-of-state-management-in-react-30hd</link>
      <guid>https://dev.to/boasbabs/the-analogy-of-state-management-in-react-30hd</guid>
      <description>&lt;p&gt;A react web application is made of several parts, called &lt;em&gt;Components&lt;/em&gt;. Components are smaller blocks of a website, for example, the Navbar, Form, Button, Tags, etc. These components some times contain data (a piece of information) or not.&lt;/p&gt;

&lt;p&gt;If a component contains data, it is called a &lt;strong&gt;Stateful&lt;/strong&gt; component else it is called a &lt;strong&gt;Stateless&lt;/strong&gt; component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class StatefulComponent extends React.Component {
  state = {
    text: "I have some internal data"
  }

  render() {
    return (
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;{this.state.text}.&amp;lt;/h2&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}


function StatelessComponent(props) {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
      &amp;lt;h2&amp;gt;I don't have any data internally&amp;lt;/h2&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Components in a web app are arranged in such a way that data flow from the &lt;em&gt;topmost&lt;/em&gt; level to the &lt;em&gt;least&lt;/em&gt; level. This is to enable same piece of data to be shared among multiple components. &lt;br&gt;
Imagine a wine glass tower. When the wine is poured to the topmost glass if filled up, it runs over to the next level glass and then to the next level and it goes on till it reaches the bottom of the glass.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mtbpJRUO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/EJqvKdxWkAAcIbC%3Fformat%3Djpg%26name%3Dsmall" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mtbpJRUO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/EJqvKdxWkAAcIbC%3Fformat%3Djpg%26name%3Dsmall" alt="wine glass tower image here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Analogy of state and props in React
&lt;/h3&gt;

&lt;p&gt;When a component has its data local or encapsulated, that data is called &lt;em&gt;state&lt;/em&gt;. That is, if a glass of wine has its own wine, we can call that wine, state. This also implies that the component can change its &lt;em&gt;"wine" (or rather data)&lt;/em&gt;.&lt;br&gt;
If the wine is coming from the previous level above, meaning the data is not local or encapsulated, we call it &lt;em&gt;Props&lt;/em&gt;. The component cannot do anything about the "wine" &lt;em&gt;flowing&lt;/em&gt; into it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why we need state management?
&lt;/h3&gt;

&lt;p&gt;Imagine you want wine in a glass six levels deep, you have to start pouring the wine from level one and keep pouring till overflows through level one, two, three, till six. You will find this exhausting in a matter of time. Hence, there ought to be a better way to get your wine. By the way, the above process is called &lt;em&gt;“Prop drilling”&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MLgHGG3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/EJqvLuxXYAMjcK4%3Fformat%3Dpng%26name%3Dsmall" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MLgHGG3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/EJqvLuxXYAMjcK4%3Fformat%3Dpng%26name%3Dsmall" alt="wine tower image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A more astute approach is to call a "bartender" whenever we need wine and he fills the exact glass you need the wine in. The job of this bartender is similar to the job of state management in React. That is, to provide the various components with the piece of data they need per time, without passing the data from components to components.&lt;/p&gt;

&lt;h3&gt;
  
  
  3 Popular ways to manage your state
&lt;/h3&gt;

&lt;p&gt;There are three major ways (but not limited to these) you can manage your state in React which&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redux (most popular way)&lt;/li&gt;
&lt;li&gt;Mobx (redux alternative)&lt;/li&gt;
&lt;li&gt;Context API (a good alternative, recently popular)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading this far, your feedback and questions are welcome.&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>javascript</category>
      <category>mobx</category>
    </item>
  </channel>
</rss>
