<?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: Raji Oluwatobiloba</title>
    <description>The latest articles on DEV Community by Raji Oluwatobiloba (@tobilastik).</description>
    <link>https://dev.to/tobilastik</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%2F342484%2F3d7a5f84-553e-4460-811f-80474a90683a.jpg</url>
      <title>DEV Community: Raji Oluwatobiloba</title>
      <link>https://dev.to/tobilastik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tobilastik"/>
    <language>en</language>
    <item>
      <title>Get Started with React Native, Redux and TypeScript</title>
      <dc:creator>Raji Oluwatobiloba</dc:creator>
      <pubDate>Tue, 28 Sep 2021 16:40:40 +0000</pubDate>
      <link>https://dev.to/tobilastik/get-started-with-react-native-redux-and-typescript-4gpi</link>
      <guid>https://dev.to/tobilastik/get-started-with-react-native-redux-and-typescript-4gpi</guid>
      <description>&lt;p&gt;One of the popular state management tools out there is Redux. &lt;/p&gt;

&lt;p&gt;Setting up a Typescript React Native Project with Redux can be tricky for beginners, in this article, I will teach you how you can easily get started.&lt;/p&gt;

&lt;p&gt;I am assuming, you have a React Native Typescript Project setup, if you don't, you can run this command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx react-native init ProjectName --template react-native-template-typescript&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your project will automatically be bootstrapped with typescript template.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installing dependencies
&lt;/h1&gt;

&lt;p&gt;I like using yarn, but you can also use npm&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add redux react-redux redux-thunk&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Afterwards, let's install redux type definitions &lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add @types/react-redux -D&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new folder call "Store".&lt;br&gt;
You can name the folder as you desire, but I prefer to use store.&lt;br&gt;
Inside this folder, create three folders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;actions&lt;/li&gt;
&lt;li&gt;reducers&lt;/li&gt;
&lt;li&gt;types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and lastly, create an index.tsx file.&lt;/p&gt;

&lt;p&gt;In your index.tsx file, paste the following code&lt;/p&gt;

&lt;pre&gt;
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import appReducer from './reducers';


export default createStore(appReducer, applyMiddleware(thunk));
&lt;/pre&gt;

&lt;p&gt;The next action is to define your Types.&lt;br&gt;
In your types folder, create an index.tsx file and paste the following code&lt;/p&gt;

&lt;pre&gt;
export const USER_TODO = 'USER_TODO';
&lt;/pre&gt;

&lt;p&gt;Save and close.&lt;/p&gt;

&lt;p&gt;Next stop is the actions folder, for this folder, I like to create an index.tsx file and other actions. So if you are creating a big application, you might have something like this&lt;/p&gt;

&lt;p&gt;&lt;code&gt;index.tsx&lt;br&gt;
users.tsx&lt;br&gt;
admin.tsx&lt;br&gt;
payment.tsx etc.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This makes your file structure cleaner and more understandable.&lt;/p&gt;

&lt;p&gt;But for this simple application, we will be needing just two files:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;index.tsx and &lt;br&gt;
todo.tsx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inside your index.tsx file, paste the code below:&lt;/p&gt;

&lt;pre&gt;
import todoAction from './todo';


export { todoAction };
&lt;/pre&gt;

&lt;p&gt;Save and Close&lt;/p&gt;

&lt;p&gt;In your todo.tsx file, you will define how your actions are to look like,&lt;/p&gt;

&lt;p&gt;First import all your types&lt;/p&gt;

&lt;pre&gt;
import { USER_TODO, } from '../types';
&lt;/pre&gt;

&lt;p&gt;Then set up your actions&lt;/p&gt;

&lt;pre&gt;
const setUserTodo = (payload: number) =&amp;gt; ({
  type: USER_TODO,
  payload,
});

export default {
  setUserTodo,
};
&lt;/pre&gt;

&lt;p&gt;Save and Close.&lt;/p&gt;

&lt;p&gt;Lastly, create two files in your reducers folder &lt;/p&gt;

&lt;p&gt;&lt;code&gt;index.tsx and &lt;br&gt;
todo.tsx&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;inside your todo.tsx file, paste the following code:&lt;/p&gt;

&lt;pre&gt;
import { USER_TODO } from '../types';

const initialstate = {
    userTodo: [],
};

type Action = {
    type: string,
    payload?: any
}

export default (state: any = initialstate, action: Action) =&amp;gt; {
    switch (action.type) {
        case USER_TODO:
            return Object.assign({}, state, {
                userTodo: action.payload,
            });
        default:
            return state;
    }
};
&lt;/pre&gt;

&lt;p&gt;inside your index.tsx file, paste the following code:&lt;/p&gt;

&lt;pre&gt;
import { combineReducers } from 'redux';
import todo from './todo';


const appReducer = combineReducers({
    todo,
});

export default appReducer;

export type State = ReturnType
&lt;/pre&gt;

&lt;p&gt;And that's it! You have successfully set up your redux store, now let's head over to the UI part.&lt;/p&gt;

&lt;p&gt;I will make use of JSON public placeholder API to generate list of todos&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;https://jsonplaceholder.typicode.com/todos/&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;&lt;/code&gt;useDispatch&lt;code&gt;&lt;/code&gt; hooks from react-redux to easily dispatch data into your reducers&lt;/p&gt;

&lt;p&gt;In your App.tsx, paste the following code:&lt;/p&gt;

&lt;pre&gt;
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { useDispatch } from 'react-redux';
import { todoAction } from '../store/actions';

interface AppProps {
  navigation: any;
  setTodo: any;
}

const Welcome: React.FC = ({ navigation: { navigate } }) =&amp;gt; {
  const dispatch = useDispatch();

  React.useEffect(() =&amp;gt; {
    loadTodos();
  }, []);

  const loadTrivia = () =&amp;gt; {
     try {
    const response = await fetch(
      'https://jsonplaceholder.typicode.com/todos/'
    );
    const json = await response.json();
     dispatch(todoAction.setUserTodo(json));
  } catch (error) {
    console.error(error);
  }
  };

  return (
    &amp;lt; View style={styles.container}&amp;gt;
      
    &amp;lt; /View&amp;gt;
  );
};

export default App;

&lt;/pre&gt;

&lt;p&gt;And to get the list of these todo, use &lt;code&gt;&lt;/code&gt;useSelector&lt;code&gt;&lt;/code&gt; hooks from react-redux&lt;/p&gt;

&lt;pre&gt;
import React from 'react';
import { View, Text } from 'react-native';
import { useSelector } from 'react-redux';

interface TodoProps {
  navigation: any;
}

const Todo = (props: TodoProps) =&amp;gt; {
  const { userTodo } = useSelector((state: State) =&amp;gt; state.todo);

const TodoList = ({data}) =&amp;gt; {
      return (
            &amp;lt; View&amp;gt;
             &amp;lt; Text&amp;gt;{data.title} &amp;lt; /Text&amp;gt;
            &amp;lt; /View&amp;gt;
      )};

  return (
      &amp;lt; FlatList
        data={userTodo}
        renderItem={({ item }) =&amp;gt; } /&amp;gt;
  )};

export default Todo;
&lt;/pre&gt;

&lt;p&gt;And that is it!&lt;/p&gt;

&lt;p&gt;That is the simple way to easily add redux to your React Native Typescript project.&lt;/p&gt;

&lt;p&gt;Let me know if you have any questions!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>redux</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>Making sense of React lifecycle methods</title>
      <dc:creator>Raji Oluwatobiloba</dc:creator>
      <pubDate>Tue, 03 Mar 2020 15:33:44 +0000</pubDate>
      <link>https://dev.to/tobilastik/making-sense-of-react-lifecycle-methods-2glb</link>
      <guid>https://dev.to/tobilastik/making-sense-of-react-lifecycle-methods-2glb</guid>
      <description>&lt;p&gt;What are React lifecycle methods?&lt;/p&gt;

&lt;p&gt;I will try and give you a simple explanation to understand this perfectly. But before that, you need to know that React components do have three phases, they are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MOUNTING&lt;/strong&gt; &lt;br&gt;
&lt;strong&gt;UPDATING&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;UNMOUNTING&lt;/strong&gt; &lt;em&gt;and&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;ERROR BOUNDARIES.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lifecycle methods can be describe as the series of events that happen through these react's four phases. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;But it is not necessary a React component goes through all these four phases. The component could get mounted and unmounted  without going through the updating phase or come down to the Error boundary phase.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let us now take a look at these phases one after the other and explain the component lifecycle method that are called in each phase.&lt;/p&gt;

&lt;h2&gt;
  
  
  MOUNTING
&lt;/h2&gt;

&lt;p&gt;In the mounting stage, React has four methods that are called in this order:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. constructor()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;2. getDerivedStateFromProps()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;3. render()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;4. componentDidMount()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constructor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the first lifecycle  method that is called before anything else, this is a good place to introduce and set your initial state.&lt;/p&gt;

&lt;p&gt;You can see from the code snippet below how I initialized my state - learnLifecycle to true.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s-LoART3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i3gyvbmh2se1g75yib51.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s-LoART3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i3gyvbmh2se1g75yib51.png" alt="constructor example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wondering why you are seeing super(props) there? What does that mean again?&lt;/p&gt;

&lt;p&gt;I don't even know myself!&lt;/p&gt;

&lt;p&gt;Just kidding, super is what initiate the parent's constructor method and allows the component to inherit methods from its parent which is Component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;getDerivedStateFromProps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the second lifecycle that is being called after constructor, it takes in two argument which is &lt;strong&gt;props&lt;/strong&gt; and &lt;strong&gt;state&lt;/strong&gt;, this method either returns an object to update the state or it returns null.&lt;/p&gt;

&lt;p&gt;This lifecycle method is called before the DOM renders, it allows a component to update its internal state in response to a change in props.&lt;/p&gt;

&lt;p&gt;It is rarely used though and unless it is absolutely necessary, you shouldn't  use it.&lt;/p&gt;

&lt;p&gt;Question: "When should I then use it???"&lt;/p&gt;

&lt;p&gt;Answer: When the change in state depends on changes in props in your component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;render&lt;/strong&gt;&lt;br&gt;
The two lifecycle methods we've seen are optional and can only be called when you define them, Render method on the other hand is required in a React component. &lt;br&gt;
This is the method that show(renders) your JSX to the DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IzR7HgmN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnyses14x713w6qzvrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IzR7HgmN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnyses14x713w6qzvrb.png" alt="render example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;componentDidMount&lt;/strong&gt;&lt;br&gt;
This is my favorite lifecycle method, because here is where magic happens! &lt;/p&gt;

&lt;p&gt;componentDidMount is called after the component is rendered.&lt;/p&gt;

&lt;p&gt;This is where you run statements that requires that the component is already placed in the DOM.&lt;br&gt;
This is a good place to initiate API calls, add event listeners, change state, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---4fQ0Qqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jqlfbofbs15woaeo7a0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---4fQ0Qqs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jqlfbofbs15woaeo7a0r.png" alt="componentDidMount example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is it for mounting phase!&lt;/p&gt;

&lt;h2&gt;
  
  
  UPDATING
&lt;/h2&gt;

&lt;p&gt;Updating stage in simple terms - when there is a change in a state or props of a react component, the component is updated. But in react, instead of "updated", it is called re-render!&lt;/p&gt;

&lt;p&gt;In the updating stage, React has five methods that are called in this order:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. getDerivedStateFromProps()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;2. shouldComponentUpdate()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;3. render()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;4. getSnapshotBeforeUpdate()&lt;/em&gt;&lt;br&gt;
&lt;em&gt;5. componentDidUpdate()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;getDerivedStateFromProps&lt;/strong&gt;&lt;br&gt;
This has been discussed already, just note that this particular method can be called both in the mounting  phase and the updating phase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;shouldComponentUpdate&lt;/strong&gt;&lt;br&gt;
The next method called after getDerivedStateFromProps is shouldComponentUpdate. It works just like the name reads, the default value for this method is True, you can return a false boolean if you don't want the component to be updated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vgzO6-Nc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xkx681mwhrca2pj84c3l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vgzO6-Nc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xkx681mwhrca2pj84c3l.png" alt="shouldComponentUpdate example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This lifecycle method is mainly use to enhance performances in our React Application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;render&lt;/strong&gt;&lt;br&gt;
Just like I explained before, render method &lt;strong&gt;should&lt;/strong&gt; also be called in the updating phase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IzR7HgmN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnyses14x713w6qzvrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IzR7HgmN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ydnyses14x713w6qzvrb.png" alt="render example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;getSnapshotBeforeUpdate and componentDidUpdate&lt;/strong&gt;&lt;br&gt;
getSnapshotBeforeUpdate lifecycle method is called right after the render method. It is called right before the DOM is updated. &lt;/p&gt;

&lt;p&gt;You can either return a value or null with getSnapshotBeforeUpdate(), the value returned is passed on to componentDidUpdate().&lt;/p&gt;

&lt;p&gt;This is also rarely use, a situation where you can use getSnapshotBeforeUpdate is when resizing the window during an async rendering (e.g. Your chat application that need to handle scroll position in a special way).&lt;/p&gt;

&lt;p&gt;Let me give you an example from the official React documentation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTJBFepz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6z9ld4phz2cxs97il76i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTJBFepz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6z9ld4phz2cxs97il76i.png" alt="getSnapshotBeforeUpdate example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  UNMOUNTING
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;componentWillUnmount&lt;/strong&gt; is the only available lifecycle method for this phase, this is the method you call when the component is about to be removed from the DOM. This is where you perform cleanups such as clearing up timers, cancelling network requests, or cleaning up any subscriptions that you created in componentDidMount().&lt;/p&gt;

&lt;p&gt;Take for example, you created an event listener in componentDidMount(), to clear it, you go like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4WQtdCUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/80pcfben8ptfq6k6ap4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4WQtdCUS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/80pcfben8ptfq6k6ap4e.png" alt="componentWillUnmount example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ERROR BOUNDARIES
&lt;/h2&gt;

&lt;p&gt;We have two lifecycles under this phase, they are:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. static getDerivedStateFromError()&lt;/em&gt; &lt;br&gt;
&lt;em&gt;2. componentDidCatch()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;static getDerivedStateFromError&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;static getDerivedStateFromError lifecycle method is invoked after an error has been thrown by a descendant component. It receives the error that was thrown as a parameter and should return a value to update state. This lifecycle method is called during rendering, so do not perform any side-effect on this method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hAwL4Edq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikx5yqwu4eim6pfqld2a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hAwL4Edq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikx5yqwu4eim6pfqld2a.png" alt="getDerivedStateFromError example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;componentDidCatch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just like static getDerivedStateFromError, it is invoked after an error has been thrown by a descendant component, but this takes an extra argument which is info, to give us more information about the error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xQB-KtLE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yo1dicp3jtrwu7iwhho2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xQB-KtLE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yo1dicp3jtrwu7iwhho2.png" alt="componentDidCatch example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;error argument on logErrorToExternalAPI above would be the actual error message and info would be the stack trace.&lt;/p&gt;

&lt;p&gt;And that is it, we have come to the end of this class! What a boring lecture...lol!&lt;/p&gt;

&lt;p&gt;React lifecycle methods may not click at once, but you can keep referring to this lecture when you get confused or ask questions.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What you need to learn before you dive into React/React Native</title>
      <dc:creator>Raji Oluwatobiloba</dc:creator>
      <pubDate>Sat, 29 Feb 2020 23:03:37 +0000</pubDate>
      <link>https://dev.to/tobilastik/what-you-need-to-learn-before-you-dive-into-react-react-native-3kgm</link>
      <guid>https://dev.to/tobilastik/what-you-need-to-learn-before-you-dive-into-react-react-native-3kgm</guid>
      <description>&lt;p&gt;Are you just starting to learn Javascript and you are already overwhelmed by those "big words" in the industry? Or you've even learned how to code in Javascript and you want to be sure if you are ready to start learning a library or a framework, then this article is for you!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React? What is React Native?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React is a Javacript library for building user interface, it was developed by Facebook. React lets you compose complex User Interface from small and isolated pieces of code called “components”.&lt;/p&gt;

&lt;p&gt;React Native is an open-sourced mobile framework, it was also created by Facebook. "RN" as I love to call it, is used to develop applications for Android, iOS and Web. RN enables you to use Javascript(React) with native platform capabilities.&lt;/p&gt;

&lt;p&gt;Enough of introduction! Let's get into the real business. As these two technologies sound attractive and it feels like you should jump into it and start learning, there are some foundations you need to make for yourself before you learn React or React Native. I am not saying without these "foundations", you won't grab React when you start learning, but in my experience, people that do this tend to struggle at it and at the end of the day, they might come back to solidify their foundation. &lt;/p&gt;

&lt;p&gt;Let me give you a list of these key things you need to learn before explaining how to go about learning it, approximated time to spend on each and resources you can make use of.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. HTML/CSS&lt;/em&gt;&lt;br&gt;
&lt;em&gt;2. Javascript&lt;/em&gt;&lt;br&gt;
&lt;em&gt;3. Basics of ES2015(ES6+)&lt;/em&gt;&lt;br&gt;
&lt;em&gt;4. React&lt;/em&gt;&lt;br&gt;
&lt;em&gt;5. React Native.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Sounds easy right? Yeah it is! At the same time, it is not!&lt;/p&gt;

&lt;p&gt;Don't let that scare you, in this article, I will break down why, how, when and where you can learn these aforementioned technologies.&lt;/p&gt;

&lt;h3&gt;
  
  
  HTML/CSS
&lt;/h3&gt;

&lt;p&gt;If you are going into web development, this two are the first technologies you will be advised to learn, and I can't stress it enough that it is important you learn them.&lt;br&gt;
I will be giving you my personal steps to learn(I used this method and I have seen many people use it too).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Learn the basics of HTML and CSS from &lt;a href="https://www.w3schools.com/html/"&gt;W3schools&lt;/a&gt; , this website is really great to get you started.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sign up on &lt;a href="https://freecodecamp.org"&gt;Freecodecamp&lt;/a&gt; , Freecodecamp is  an interactive learning web platform where there is a curriculum to follow, you practice as you learn a feature. Check it out! It is free and a very good resource to solidify your knowledge.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you prefer to learn with videos, there are tons of youtube channels you can learn from. I recommend &lt;a href="https://www.youtube.com/user/TechGuyWeb"&gt;Traversy Media&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start building 'stuffs'. The only way to get better at coding is to experiment with the things you learn, don't just learn and feel you know it, BUILD SOMETHING!!, Real world project! I know you are already wondering why I am screaming at you, but you can't just skip that step. Luckily, &lt;a href="https://freecodecamp.org"&gt;Freecodecamp&lt;/a&gt; has a lot of projects for you to test your skills.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I feel one month or less is okay for you to get a good grasp of HTML and CSS(I am not saying you will become a Pro in one month), but you will have a solid knowledge of how these two technologies work and what you can do with them.&lt;/p&gt;

&lt;h3&gt;
  
  
  JAVASCRIPT
&lt;/h3&gt;

&lt;p&gt;It is very &lt;strong&gt;important&lt;/strong&gt; you have a good grasp of Javacript before you think of learning React. Why? React is Javascript, when you start learning React, many tutorials you will find online will assume you have the knowledge of Javascript, do not let anybody deceive you that you can know React without learning Javascript, there is no shortcut to it. Even if you manage to do that in some way, you will still always come back to learn how some things work in vanilla Javascript.&lt;br&gt;
Hey Tobi, what is vanilla Javascript again??? Chill, it's just another name for Javascript, it is pure Javascript, the vanilla is just a general term to stress it, as in your normal vanilla ice-cream, without flavors.&lt;/p&gt;

&lt;p&gt;Back to business! &lt;/p&gt;

&lt;h4&gt;
  
  
  Resources to learn Javascript
&lt;/h4&gt;

&lt;p&gt;There are many resources online to learn Javascript that you might get lost on which to use. Yeah! I was once in your shoes!&lt;br&gt;
But just like the steps I wrote for HTML/CSS. You can follow that to also learn Javascript.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Start with &lt;a href="https://www.w3schools.com/js/"&gt;W3schools&lt;/a&gt; to get both the basics and advance knowledge of Javascript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hands down to &lt;a href="https://freecodecamp.org"&gt;Freecodecamp&lt;/a&gt; when it comes to Javascript, they have over 300 interactive lessons on Javascript and more than 10 Projects to build after learning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For videos, I will also recommend &lt;a href="https://www.youtube.com/user/TechGuyWeb"&gt;Traversy Media&lt;/a&gt; .&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I don't think I need to remind you that the key to understanding Javascript is to build real-world applications. Shoutout to &lt;a href="https://twitter.com/WellPaidGeek"&gt;Well Paid Geek&lt;/a&gt; for his constant reminder on this! &lt;br&gt;
It is very &lt;strong&gt;important&lt;/strong&gt; aspect of programming, you can't get better till you start doing it yourself, video tutorials might show you how to do it, but doing it yourself will build your brain muscles. &lt;/p&gt;

&lt;p&gt;I can't really tell you a timeline to learn Javascript because you can't stop learning it! But I would say 4-6 months is a reasonable time to go through aforementioned resources. &lt;/p&gt;

&lt;p&gt;So Tobi, is this the right time to learn &lt;strong&gt;React&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;No chill bro, aren't you missing something? &lt;strong&gt;ES2015+!!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is ES2015+ or ES6+?&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=9A_jkh2AKR8"&gt;LevelUp Tuts&lt;/a&gt; does justice to this question in this short video.&lt;/p&gt;

&lt;p&gt;But in summary, ES6 and above are modern version of Javascript, there are different changes such as arrow functions, the rest/spread operator, import/export statements, variable destructuring, etc. and it is essential you know them as they are used by frameworks and libraries(React in our case).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources to learn ES6&lt;/strong&gt;&lt;br&gt;
These days, modern website, tutorials and books teach ES6 with Javascript, as it is Javascript itself, but if you find yourself in a situation where you feel you didn't learn enough of it in any resources you used, you can check out this &lt;a href="https://hacks.mozilla.org/category/es6-in-depth/"&gt;Mozilla tutorial&lt;/a&gt; or this introductory course by &lt;a href="https://www.youtube.com/watch?v=IEf1KAcK6A8"&gt;Academind&lt;/a&gt; , &lt;a href="https://www.youtube.com/user/TechGuyWeb"&gt;Traversy Media&lt;/a&gt; also has tons of tutorials on ES6.&lt;/p&gt;

&lt;p&gt;I said earlier that 4-6 months should be enough to go through these resources, but it doesn't mean you will be a Pro in this period of time, nobody does unless they've been doing it for years! &lt;/p&gt;

&lt;p&gt;"So Tobi when is the right time to dive into React?"&lt;/p&gt;

&lt;p&gt;"The question should be how many projects have I built with Javascript?"&lt;/p&gt;

&lt;p&gt;If your answer is not between the range of 10-infinity, then you should get to work. &lt;/p&gt;

&lt;p&gt;Because everybody is learning React doesn't mean you have to jump into it too. Solidify your Javascript foundation, master your craft very well! It is very important! Do not rush yourself.&lt;/p&gt;

&lt;p&gt;Spend good amount of time, practice, practice and practice. &lt;/p&gt;

&lt;p&gt;Even if you have exhausted all the resources I have given above, try learning more in-depth Javascript.&lt;/p&gt;

&lt;p&gt;I will recommend this &lt;a href="https://github.com/getify/You-Dont-Know-JS"&gt;Book series&lt;/a&gt; by Kyle Simpson and also &lt;a href="https://eloquentjavascript.net/Eloquent_JavaScript.pdf"&gt;Eloquent Javascript&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;These two books are books I still reference till date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fast forward to a year later!!!&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;You can now start learning React&lt;/strong&gt;.  &lt;em&gt;smiles&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Some people might argue that a year is too much to learn the prerequisites to React, but it doesn't matter, so far you are confident in yourself that your Javascript knowledge is solid enough, you can start learning React.&lt;/p&gt;

&lt;p&gt;So the big question comes in. &lt;strong&gt;How do I start learning React&lt;/strong&gt;&lt;br&gt;
Even though it is out of the scope of this article, but I will give brief intro to it and maybe in my next article, we will discuss this further.&lt;/p&gt;

&lt;p&gt;Maybe you have read nice things about React Native(like me when I started) and you would rather become a full React Native developer that being a Web developer/React developer.&lt;/p&gt;

&lt;p&gt;You might start asking, &lt;strong&gt;Should I learn React before React Native?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes! Yes!! and Yes!!!&lt;/p&gt;

&lt;p&gt;Some people may still disagree with me on this, but the truth of the matter is &lt;strong&gt;React Native is still React&lt;/strong&gt;, the only difference is that you are building for mobile for one and one is for the web.&lt;/p&gt;

&lt;p&gt;"Okay, Tobi, I am confused here, if React Native is React, why shouldn't I just go ahead and learn React Native and start building apps instead of wasting my time on React?"&lt;/p&gt;

&lt;p&gt;Well, the reason is that you will hardly find React Native tutorials, courses or videos that will teach you React, most will assume you have the  knowledge of React. Even the official documentation of React Native does not teach you React. You should know the underlying principles before jumping into React Native.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So where should you start from?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I would say the &lt;a href="https://reactjs.org/docs/getting-started.html"&gt;Official documentation of React&lt;/a&gt; is the best place to start.&lt;/p&gt;

&lt;p&gt;Like I said before, learning React is out of the scope of this article.&lt;br&gt;
The goal of this article is to tell you the important things to learn before diving into React.&lt;/p&gt;

&lt;p&gt;If you have any questions or contributions, let me know in the comment section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking!!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
