<?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>Forem: Kinginthenorthcodez </title>
    <description>The latest articles on Forem by Kinginthenorthcodez  (@kinginthenorthcodez).</description>
    <link>https://forem.com/kinginthenorthcodez</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%2F862010%2Fc025aaa1-d122-40f6-8b11-f4464492e46b.jpeg</url>
      <title>Forem: Kinginthenorthcodez </title>
      <link>https://forem.com/kinginthenorthcodez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kinginthenorthcodez"/>
    <language>en</language>
    <item>
      <title>Data structure everywhere</title>
      <dc:creator>Kinginthenorthcodez </dc:creator>
      <pubDate>Sat, 18 Feb 2023 17:51:36 +0000</pubDate>
      <link>https://forem.com/kinginthenorthcodez/data-structure-everywhere-3ome</link>
      <guid>https://forem.com/kinginthenorthcodez/data-structure-everywhere-3ome</guid>
      <description>&lt;p&gt;See last time i talked about how data structures is everywhere around us.&lt;br&gt;
And i start by making an analogue of an array data structure and how its everywhere in our lives. Now its time expand more on that and see what other data structures are and how do we use them in our everyday bustling lives.&lt;/p&gt;

&lt;p&gt;Well if you're a programmer you obviously know that you could and can create an entire world of your imagination into a digital world and they is no shortage of variables in your construct.&lt;br&gt;
But all these variables are inspired by what you get or altleast perceive in the real world.&lt;/p&gt;

&lt;p&gt;So you have these two worlds, one you could test out the variables and the other you could live or are living out the variables, you have two world complementing each other. For example you have an Array data structure that you can use to understand persive dimensions in the digital world to modeling 3D -N dimensions that you couldn't but otherwise understand in the real world. Okay so lets get started. 😃&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays data structure
&lt;/h2&gt;

&lt;p&gt;We start with Arrays data structure beacuse its the fundamental to most of the data structures that we have or know exist.&lt;br&gt;
Defination of an array data structure is that, its one that stores or holds items of same type in a sequential or contiguous memory location and actions or operations on its elements are performed in sequence at the very least.&lt;br&gt;
In the real world we have this playing out, your very growth is an arrangement of an array of growth. You start out small, and then big.&lt;br&gt;
Your schedule or daily routine, your walking of every step you take provided you know the next step then you can skip to it otherwise its step by step or journey, your packing of your favorite things in a box or counting . The arrangement of the petals on a flower or the finger prints. And so on, all we have or are doing is a step by step process and a defined fixed size at the time of start. This way you can never grow any taller or bigger than whats already defined in your array structure (genetically ) or go beyond than whats already your destination of your journey.&lt;/p&gt;

&lt;p&gt;So what you see here, is this fascinating implementation of such a data structure in the digital world by these very smart dedicated programmers. On a larger or more grandeur scale is the universe, in it many other other universes or worlds all but within other worlds otherwise, until we get to our world. Science call this dimensions or multiverse. And lo and behold these programmers figures it out that the array can have or hold multiple arrays in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multidimensional Arrays
&lt;/h2&gt;

&lt;p&gt;And arrays in digital world gets to hold or store other arrays in them.&lt;br&gt;
So you have a 1dimensional array or simple array and a 2D, 3D, Nth D or multidimensional array. Allowing the digital world to visualize or render its world in any dimensional needed. This changed everything, we could now persive any dimension on our screens.&lt;/p&gt;

&lt;p&gt;But soon the programmers would realise that thier digital world could only keep up this much with arrays data structure, now arrays would be limited only to that extent. Because no implementation hardware or software, can model a mathematical concept completely.To ensure predictability of such a powerful data structure constrained by its digital world, these clever and smart programmers devised a standard that would allow aleast not more than 10D (dimensions ) of array to be defined. As this is what most compilers would handle or they risk their digital world run into cheos😃.&lt;/p&gt;

&lt;p&gt;To compasate for these limitations such as fixed size and sequential storage of data they had to look for new ways of storing data that could be stored at non-contiguous memory locations.It is important to recognize the limitations of a particular implementation. Often it will be possible to present several implementations of the same data type each with its own strength and weakness.And we going to see such data structures in our real world later on. Now lets see how this Array data structure is implemented, used in the digital world.&lt;br&gt;
To be continued..&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>cpp</category>
    </item>
    <item>
      <title>How State in React works?</title>
      <dc:creator>Kinginthenorthcodez </dc:creator>
      <pubDate>Fri, 06 Jan 2023 06:54:07 +0000</pubDate>
      <link>https://forem.com/kinginthenorthcodez/how-state-in-react-works-41ha</link>
      <guid>https://forem.com/kinginthenorthcodez/how-state-in-react-works-41ha</guid>
      <description>&lt;p&gt;Hello! It's me again, your React Toist😁. This is a 2/4 part article highlighting some React concepts, check &lt;a href="https://dev.to/kinginthenorthcodez/react-state-in-2-min-27bo"&gt;React state in 2 min&lt;/a&gt;.Lets dive in🏊🏽.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywk7umw3xlx2ifo60gv6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywk7umw3xlx2ifo60gv6.gif" alt="Squiddy toist" width="224" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mutation on state
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mutation is the ability to affect change and react provides a
clear rule or guidline on how to affect the react state.&lt;/li&gt;
&lt;li&gt;React says no direct change is allowed on state, any changes or 
update should be done through the state function updater that 
react provides at the time of creating the state.&lt;/li&gt;
&lt;li&gt;Lets consider this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React {useState} from 'react'
  const StateInReact= () =&amp;gt;{
   //creates and gives initial value
   const[title, setTitle]= useState('State in React!') 
    //Not allowed!
    title= "New state value"
   // Allowed
    setTitle('new state value')
  return(&amp;lt;h1&amp;gt;{title}&amp;lt;/h1&amp;gt;) //access state
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scope and Access
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In React state is either local to the compenent(component state) 
or global to all components(app state) also known as shared state. And this defines scope to which component can access that state.&lt;/li&gt;
&lt;li&gt;Every component can defined its own state and share it with other components that need access to or use that state.&lt;/li&gt;
&lt;li&gt;React allows this by passing down state data from a parent 
component(component that defined state) to child 
component(component recieving state) through whats called props 
short for (properties) or prop drilling.&lt;/li&gt;
&lt;li&gt;Its this techique that allows state to be shared among 
components that needs it.&lt;/li&gt;
&lt;li&gt;Lets consider this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import React {useState} from 'react'
  const StateInReact= () =&amp;gt;{
   //creates and gives initial value
   const[title, setTitle]= useState('State in React!') 
    //Not allowed!
    title= "New state value"
   // Allowed
    setTitle('new state value')
  return(
         &amp;lt;&amp;gt;
          &amp;lt;AnotherComp title = {title}/&amp;gt; //pass state as prop
         &amp;lt;/&amp;gt;
       ) 
}

const AnotherComp =(props)=&amp;gt; {
return(&amp;lt;h1&amp;gt;{props.title}&amp;lt;/h1&amp;gt;) // access state from props
}


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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;But this way of state sharing would bring unneccessary work
for other child components that have no use of the state but 
just to pass it along down to the next, until the one that has 
use for it. &lt;/li&gt;
&lt;li&gt;Solution? React allows you also to define a global state , so 
that any component can access it directly and use the state 
whenever needed.&lt;/li&gt;
&lt;li&gt;This is possible by defining a context(scope) through the 
context API, that hooks state to a provider wraping your 
application or main component in your app.&lt;/li&gt;
&lt;li&gt;Thats how global state is provided and achieved in your react app.&lt;/li&gt;
&lt;li&gt;Lets consider this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; import React, { useState, useContext } from 'react';
import data from '../birthday/Data';

const PersonContext = React.createContext(); // has two components named provider and consumer
const ContextAPI = () =&amp;gt; {
  const [people, setPeople] = useState(data);
  const removeItem = (id) =&amp;gt; {
    setPeople((people) =&amp;gt; {
      return people.filter((person) =&amp;gt; person.id !== id);
    });
  };
  return (
    &amp;lt;PersonContext.Provider value={{ removeItem, people }}&amp;gt;
      &amp;lt;h2&amp;gt;ContextAPI&amp;lt;/h2&amp;gt;
      &amp;lt;List /&amp;gt;
    &amp;lt;/PersonContext.Provider&amp;gt;
  );
};

const List = () =&amp;gt; {
  const { people } = useContext(PersonContext);
  return (
    &amp;lt;&amp;gt;
      {people.map((person) =&amp;gt; {
        return &amp;lt;SinglePerson key={person.id} person={person} /&amp;gt;;
      })}
    &amp;lt;/&amp;gt;
  );
};

const SinglePerson = ({ person }) =&amp;gt; {
  const { removeItem } = useContext(PersonContext);
  return (
    &amp;lt;div key={person.id}&amp;gt;
      &amp;lt;h4&amp;gt;{person.name}&amp;lt;/h4&amp;gt;
      &amp;lt;button type='button' onClick={() =&amp;gt; removeItem(person.id)}&amp;gt;
        remove
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ContextAPI;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This way of state management is okay when your app is small and does not involve complex state logic.&lt;/li&gt;
&lt;li&gt;But as your app scales or grow you would need to use dedicated 
tools for managing your state such as  &lt;a href="https://redux.js.org/introduction/getting-started" rel="noopener noreferrer"&gt;Redux&lt;/a&gt;, &lt;a href="https://mobx.js.org/README.html" rel="noopener noreferrer"&gt;MobX&lt;/a&gt; etc&lt;/li&gt;
&lt;li&gt;On how to use such state management tools like Redux , i will 
do a separate article on that. So do look out for it once it's 
published. &lt;/li&gt;
&lt;li&gt;You can also check out the source code on my &lt;a href="https://github.com/kinginthenorthcodez/oraion" rel="noopener noreferrer"&gt;github&lt;/a&gt; were i have documented this &lt;a href="https://github.com/kinginthenorthcodez/oraion/blob/5ed68bf3a83862a88ce9b6c16fa878a352883034/src/1-contextAPI/contextAPI.js" rel="noopener noreferrer"&gt;resource&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sycronization
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Sycronization is the ability to respond or react to updates and 
changes in data/state across data and rendering components.&lt;/li&gt;
&lt;li&gt;What this means is that, when your data or state updates or changes, every other component that uses or access that data ,should be able to recieve and update its data with the current state/data.&lt;/li&gt;
&lt;li&gt;This gives the app or component ability to update UI/re- 
rendering with current state.&lt;/li&gt;
&lt;li&gt;A simple example is form that uses controlled inputs.&lt;/li&gt;
&lt;li&gt;You can also archive this with React-router data apis. Will 
write and show you how in my next article about react-router's 
super powers🥷🏽.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Every time you update state data that UI uses, you send that 
data to UI so it can update its UI acordingly. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One directional flow of data
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Providing a single source of truth is how react state manages 
its state or data.&lt;/li&gt;
&lt;li&gt;We have seen this on mutatation of state and this why.&lt;/li&gt;
&lt;li&gt;This is also the basic principle for all state management 
libraries like redux and state immutabality is archied.&lt;/li&gt;
&lt;li&gt;For a more indepth about this will be convered in redux and 
state management in react.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Whether you building a small app or complex app , you will want 
to store some data, to provide a custom experience to the user(aka 
user experience).&lt;/li&gt;
&lt;li&gt;And state is how you archieve just that in react, therefore 
knowing how state works is the right direction to put your feet 
in waters of React.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Hope you had a wonderful read ,and some quetion answered.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy coding!!🚀&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>React state in 2 min</title>
      <dc:creator>Kinginthenorthcodez </dc:creator>
      <pubDate>Sat, 05 Nov 2022 20:46:25 +0000</pubDate>
      <link>https://forem.com/kinginthenorthcodez/react-state-in-2-min-27bo</link>
      <guid>https://forem.com/kinginthenorthcodez/react-state-in-2-min-27bo</guid>
      <description>&lt;p&gt;Dear reader,this is going to be a 4 part series article highlighting the following concepts on state in react.&lt;br&gt;
On a lighter note,did you know you just discovered a gem in the react mines 😁. Here!&lt;/p&gt;
&lt;h2&gt;
  
  
  What is State in React?
&lt;/h2&gt;
&lt;h2&gt;
  
  
  How State in React works?
&lt;/h2&gt;
&lt;h2&gt;
  
  
  Types of State in React
&lt;/h2&gt;
&lt;h2&gt;
  
  
  What is Lifting State Up in React?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvj179r391g8p24fkdkz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvj179r391g8p24fkdkz.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Okay, lets get started!&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is State in React?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React Provides a dynamic data store for each component&lt;/li&gt;
&lt;li&gt;The internal data represents the state of a react component and can be accessed using the state member variable of that react component.&lt;/li&gt;
&lt;li&gt;Whenever the state of the component changes, the component re-renders along with its new state by calling the render() method.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Summary:
&lt;/h3&gt;

&lt;p&gt;The state represents the value of dynamic properties of a React component's data at a given instance. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  How to define State in React?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;They are two ways to define the state in React, using the setState API and useState Hooks API respectively.&lt;/li&gt;
&lt;li&gt;Will focus on the useState hook API for functional components&lt;/li&gt;
&lt;li&gt;React state should not be modified directly through the state member variable and updating the state through the member variable does not re-render the component.&lt;/li&gt;
&lt;li&gt;to define state simply import the  useState hook
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;const [myState, setMyState] = useState({name: 'Jon'})&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To access the state simply :
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;p&amp;gt;{myState.name}&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To update state simply:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleState =() =&amp;gt; {
    setMyState ({name: 'Jane', age: 27})
}

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;We can update any one of the state fields at a time instead of updating the whole object. This feature gives the developer the flexibility to easily handle the state data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In react whenever the state is inferred or defined it simply means the status of the application or component at any given instance and that allows it to be aware of its environment to respond to requests and updates accordingly.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>state</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Data structure everywhere</title>
      <dc:creator>Kinginthenorthcodez </dc:creator>
      <pubDate>Fri, 13 May 2022 16:57:29 +0000</pubDate>
      <link>https://forem.com/kinginthenorthcodez/data-structure-everywhere-292d</link>
      <guid>https://forem.com/kinginthenorthcodez/data-structure-everywhere-292d</guid>
      <description>&lt;p&gt;Everywhere we look and everything we use has in some degree a data structure implemented. If we look close enough to observe the intricates of the world arround us , soon will start picking up parttens on how everything arround us fits in just right.&lt;/p&gt;

&lt;p&gt;In the world of quatum mechanics and science , our world itself is a marvel . From how just they seem to be enough room for everyone and a constant time to chip in the right seasons and moments. Most renowed scientist and physicist have called this a dimenssion . &lt;/p&gt;

&lt;p&gt;And now using real world examples to mirror how data structure is impelemented in the digital world.&lt;/p&gt;

&lt;p&gt;Post to be continued…&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>datascience</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
