<?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: Martha Onuh</title>
    <description>The latest articles on Forem by Martha Onuh (@martha).</description>
    <link>https://forem.com/martha</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%2F615525%2F13966c1d-9e41-47e0-8441-65b79d445503.jpg</url>
      <title>Forem: Martha Onuh</title>
      <link>https://forem.com/martha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/martha"/>
    <language>en</language>
    <item>
      <title>My Goals for HNG (8) Internship</title>
      <dc:creator>Martha Onuh</dc:creator>
      <pubDate>Mon, 16 Aug 2021 16:23:12 +0000</pubDate>
      <link>https://forem.com/martha/my-expectations-for-hng-8-internship-360d</link>
      <guid>https://forem.com/martha/my-expectations-for-hng-8-internship-360d</guid>
      <description>&lt;p&gt;My name is Martha Onuh, a young graduate of computer Science from the Benue State University, Makurdi and I am a frontend developer.&lt;br&gt;
Fortunately, as I love to put it, I got accepted into the HNG (8) internship from the &lt;a href="https://zuri.team"&gt;Zuri Team&lt;/a&gt; for the Frontend development track. I must say that I am very excited to be part of these internship and I have some goals and expectations for the internship which  I intend to share in these article.&lt;/p&gt;

&lt;p&gt;For this internship, my major goal is to improve on my existing skills. I consider this a great opportunity for me to improve on my skills as this is my greatest expectation in this program. I already have existing knowledge in HTML, CSS, JavaScript, React, Bootstrap, Git and Github. I see this program as a great place for me to improve on this skills. I also hope to achieve the following at the end of this program which will last for a period of six weeks.&lt;/p&gt;

&lt;p&gt;It is my goal to be among the finalist for this internship. I have heard so much about how people drop out along the way but I am determined to get to the last stage of these program and be among the finalist.&lt;br&gt;
Also, I would like to meet new people and expand my network, I really hope I can get to achieve this because I am not so much of the social type and as such I have very little friends and network, so I hope that with the help of this program I can get to meet new people and expand my network.&lt;/p&gt;

&lt;p&gt;I have also included a link to some of my favorite beginner tutorials;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://trydesignlab.com/figma-101-course/introduction-to-figma/"&gt;Introduction to designing with Figma&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/what-is-git-and-how-to-use-it-c341b049ae61/"&gt;Introduction to Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/html-introduction/"&gt;Introduction to HTML&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://careerfoundry.com/en/tutorials/web-development-for-beginners/an-introduction-to-javascript/"&gt;Introduction to JavaScript&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks for reading😊.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding React Hooks</title>
      <dc:creator>Martha Onuh</dc:creator>
      <pubDate>Sun, 09 May 2021 13:46:56 +0000</pubDate>
      <link>https://forem.com/martha/understanding-react-hooks-259h</link>
      <guid>https://forem.com/martha/understanding-react-hooks-259h</guid>
      <description>&lt;p&gt;Before the introduction of Hooks, we could only create and manage State using a class-based component, we couldn't do such with a functional component as it was a stateless component, but with the introduction of Hooks in React 16.8, we can now use state and other React features without a class.&lt;/p&gt;

&lt;p&gt;We define a Hook according to the official React documentation as "a special function that lets you 'hook into' React features". So you do not need to rewrite a functional component to a class component before you can add State but you can use a Hook inside the functional component to add State. &lt;/p&gt;

&lt;p&gt;Let us look at the first React Hook which is the &lt;code&gt;useState&lt;/code&gt; (Hook State).&lt;br&gt;
To use it you would need to import it&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;After importing it, we can now use Hook in this way;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {useState} from 'react'

const App=()=&amp;gt; {
  const [count, setCount] = useState(0);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h4&amp;gt;You clicked {count} times&amp;lt;/h4&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Click me
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see from the code above that the value of &lt;code&gt;useState&lt;/code&gt; is the initial value of state when we load our application (0), we then increment &lt;code&gt;state.count&lt;/code&gt; when a user clicks a button by calling the &lt;code&gt;this.setState()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let us create the equivalent of the above application using a class component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class App extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        count: 0
      };
    }

    render() {
      return (
        &amp;lt;div&amp;gt;
          &amp;lt;p&amp;gt;You clicked {this.state.count} times&amp;lt;/p&amp;gt;
          &amp;lt;button onClick={() =&amp;gt; this.setState({ count: this.state.count + 1 })}&amp;gt;
            Click me
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      );
    }
  }
  export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see that from both cases we had to read state and then update state.&lt;br&gt;
&lt;strong&gt;Things to note when using Hook&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You can only call hook at the top level and not inside of a condition, a loop, or a nested function.&lt;/li&gt;
&lt;li&gt;Hooks can only e called inside of a React component and not inside a regular JavaScript function.&lt;/li&gt;
&lt;li&gt;You can also declare more than one state variable (multiple variables).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Another React Hook we will be looking at is the &lt;code&gt;useEffect&lt;/code&gt; (Hooks Effect) it allows us to perform a side effect (actions) on functional components. The &lt;code&gt;useEffect&lt;/code&gt; does not use life cycle methods (componentDidMount(), componentDidUpdate() and componentWillUnmount() ) that are used in a class component.&lt;br&gt;
The most common feature of &lt;code&gt;useEffect&lt;/code&gt; is in fetching and consuming data from an API and also updating the DOM (Document Object Model). &lt;/p&gt;

&lt;p&gt;We will take a look at how we can use &lt;code&gt;useEffect&lt;/code&gt; to fetch data from an API. &lt;/p&gt;

&lt;p&gt;We are going to be building a News application that displays the latest news within our region. We are getting our data from &lt;code&gt;newsapi.org&lt;/code&gt; So below is our &lt;code&gt;/App.js&lt;/code&gt; component. We created a state for news, with an empty useState, after fetching data from the API, we set our state to the data we got.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useEffect, useState } from 'react'
import News from './News'
import './App.css'

const App=()=&amp;gt;{

  const [news, setNews] = useState([])

    useEffect( () =&amp;gt;{
        getNews()
    }, [query]);

    const getNews = async ()=&amp;gt;{
        const response = await fetch(`https://newsapi.org/v2/top-headlines?country=ng&amp;amp;apiKey=YOUR-API-KEY`)
        const data = await response.json()
        setNews(data.articles) 
    }
    return(
        &amp;lt;div className="App"&amp;gt;
  {news.map(news =&amp;gt;(
              &amp;lt;News
              key={news.title}
              title={news.title}
              author={news.source.name}
              date={news.publishedAt}
              description={news.description}
              link={news.url}
              photo={news.urlToImage}

               /&amp;gt;
            ))}
        &amp;lt;/div&amp;gt;
    )
}
export default App;

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

&lt;/div&gt;



&lt;p&gt;Below is our &lt;code&gt;/News.js&lt;/code&gt; component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

const News =({title, author, date, description, link, photo})=&amp;gt;{
    return(
        &amp;lt;div className="row news"&amp;gt;
            &amp;lt;div className="col-md-6"&amp;gt;
            &amp;lt;h3&amp;gt;{title}&amp;lt;/h3&amp;gt;
            &amp;lt;h6&amp;gt;Source: {author}&amp;lt;/h6&amp;gt;
            &amp;lt;h6&amp;gt;Publication Date: {date}&amp;lt;/h6&amp;gt;
            &amp;lt;p&amp;gt;{description} &amp;lt;a href={link}&amp;gt;Read Content&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div className="col-md-6"&amp;gt;
            &amp;lt;img className="img-fluid justify-content-center" src={photo} alt="..."  width="600px"/&amp;gt;

            &amp;lt;/div&amp;gt;

        &amp;lt;/div&amp;gt;
    )
}
export default News;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see from the above that in using the &lt;code&gt;useEffect&lt;/code&gt; to fetch data from an API, we do not use the lifecycle method as used when doing so in a class-based component.&lt;/p&gt;

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

&lt;p&gt;React hook is a great addition to the library and an interesting aspect of React Js as understanding it will help you to include state in functional component, there are other things to understand in Hooks, and will advise that you read through the official documentation for more understanding.&lt;br&gt;
You can get the complete project on everything on this article &lt;a href="https://github.com/Marthacode/React-Hooks-news-app"&gt;here&lt;/a&gt;. &lt;br&gt;
Thanks for reading!😊&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>React Props and State</title>
      <dc:creator>Martha Onuh</dc:creator>
      <pubDate>Wed, 05 May 2021 12:36:14 +0000</pubDate>
      <link>https://forem.com/martha/react-props-and-state-2f5e</link>
      <guid>https://forem.com/martha/react-props-and-state-2f5e</guid>
      <description>&lt;p&gt;If you are just getting started with React JS, I understand that it can be really confusing getting to understand these concepts and how you can use them, so I decided to write this article to explain these concepts as simply as possible.&lt;/p&gt;

&lt;p&gt;So to begin with, &lt;strong&gt;what do Props mean in React?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Props is the short form of properties and they are used to pass data from one component to another. The flow of this data is always in one direction (uni-directional) from parent to child component. It should also be noted that the data that is passed is always read-only and should not be changed.&lt;br&gt;
Think of props as an object that contains the attribute and their values which have been passed from the parent component. Props make it possible to reuse components.&lt;/p&gt;

&lt;p&gt;Let's take a look at an example;&lt;br&gt;
We have a simple component &lt;code&gt;/SayHello.js&lt;/code&gt; that output a simple message&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

const SayHello =()=&amp;gt;{
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;Hello and welcome onboard&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}
export default SayHello;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we render this component in our &lt;code&gt;/App.js&lt;/code&gt; component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import SayHello from './SayHello'

const App=()=&amp;gt;{
  return(
    &amp;lt;div&amp;gt;
      &amp;lt;SayHello /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So this is a sample of a simple component without props, however, what if we would like to add a name property to the SayHello Message and we do not want to hardcode it into the h1 so as we can change the name we SayHello to with ease.&lt;/p&gt;

&lt;p&gt;So this is where we introduce props into our components, so the &lt;code&gt;/SayHello.js&lt;/code&gt; will now look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

const SayHello =(props)=&amp;gt;{
    return(
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;Hello and welcome onboard {props.name}&amp;lt;/h1&amp;gt;
        &amp;lt;/div&amp;gt;
    )
}
export default SayHello;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While the name properties (props) will also be added to our &lt;code&gt;/App.js&lt;/code&gt; component in this way&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import SayHello from './SayHello'

const App=(props)=&amp;gt;{
  return(
    &amp;lt;div&amp;gt;
      &amp;lt;SayHello name="Martha" /&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}
export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So you can see how simple it is to introduce props into our components, we simply need to add the property (in this case name) to the component and add the Props.(whatever property) we are passing to where we want to call it.&lt;/p&gt;

&lt;p&gt;Let's also look at how we can use props in a class component (note that our first example is a functional component).&lt;/p&gt;

&lt;p&gt;So in a class component, our &lt;code&gt;/SayHello.js&lt;/code&gt; will look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class SayHello extends React.Component{
    render(props){
        return(
            &amp;lt;div&amp;gt;
               &amp;lt;h1&amp;gt;Hello and welcome onboard {this.props.name}&amp;lt;/h1&amp;gt;
            &amp;lt;/div&amp;gt;
        )
    }
}
export default SayHello;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we have seen how props work in both function and class components.&lt;/p&gt;

&lt;p&gt;Now let's take a look at &lt;strong&gt;States&lt;/strong&gt;&lt;br&gt;
Just like props, State holds information about a component, it allows components to create and manage their own data, so while components pass data with Props, they create and manage data with States. This means that a component state can change, and whenever it changes the component re-renders&lt;/p&gt;

&lt;p&gt;let's take a look at an example of a Component creating and managing data with States.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class Record extends React.Component{
    constructor(props){
    super(props)
    this.state={
        count : 0
    }
    this.handeClick = this.handeClick.bind(this)
    }
    handeClick(){
        this.setState(prevState =&amp;gt;{
            return{
                count:prevState.count + 1
            }
        })
    }
    render(){
        return(
            &amp;lt;div&amp;gt;
                &amp;lt;h1&amp;gt;{this.state.count}&amp;lt;/h1&amp;gt;
                &amp;lt;button onClick={this.handeClick}&amp;gt;Change&amp;lt;/button&amp;gt;
            &amp;lt;/div&amp;gt;
        )
    }
}

export default Record;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above example, it can be seen that the Record component had a count state which is initially set to zero, but this state is changed by the action of a button click. You can see that the button has an onClick that calls the function "handleClick" which is set to change the initial state of count using the setState method.&lt;/p&gt;

&lt;p&gt;One important thing to note is that in the early days that is before now, State could only be used in class component and not in functional component (this is why functional components were referred to as Stateless components) but with the introduction of React Hooks, State can now be used in functional components also. I will write about React Hook in my next article.&lt;/p&gt;

&lt;p&gt;From all we have looked at in this article we can draw the following differences between Props and State in React.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Props are used to pass data while State is used to manage data.&lt;/li&gt;
&lt;li&gt;Components use Props to receive data from outside while components create and manage their own data with State.&lt;/li&gt;
&lt;li&gt;Props can only be passed from parent to child component and they are read-only.&lt;/li&gt;
&lt;li&gt;State can be modified in its own component and this must be done using the &lt;code&gt;setState()&lt;/code&gt; method.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;Props and State are very important concepts in React JS and understanding how to use them is very crucial, Getting a solid understanding of these two would help your React journey. Feel free to leave a comment below and I would also like to hear from you about anything you need clarity on.&lt;br&gt;
&lt;a href="https://github.com/Marthacode/React-Props-and-State"&gt;The complete project on everything on this article can be found here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>frontend</category>
    </item>
    <item>
      <title>A Simple Introduction to React JS</title>
      <dc:creator>Martha Onuh</dc:creator>
      <pubDate>Tue, 20 Apr 2021 09:55:53 +0000</pubDate>
      <link>https://forem.com/martha/a-simple-introduction-to-react-js-1cie</link>
      <guid>https://forem.com/martha/a-simple-introduction-to-react-js-1cie</guid>
      <description>&lt;p&gt;React is one of the most popular JavaScript library used for building user interfaces or UI components. React makes the process of building interfaces easier by dividing the UI into a collection of components. React is simple, fast and scalable, it allows developers to create large web applications that can change data, without reloading the page.&lt;br&gt;
React is mostly concerned with state management and rendering that state to the DOM(Document Object Model), so creating React applications usually requires the use of additional libraries for routing, as well as certain client-side functionality.&lt;br&gt;
Before going into React a good understanding of HTML, CSS, and basic JavaScript is needed, you don't have to be a JavaScript expect, but a good knowledge of JavaScript would be very helpful (knowing things like; variables, object and array destruturing, arrow functions, callbacks, template literals and ES6 Modules).&lt;br&gt;
In these article we will be looking at the basic features to get you started.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;The most simple and beginner friendly way of installing ReactJs is by installing &lt;strong&gt;create-react-app&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;Create-react-app&lt;/strong&gt; is a comfortable environment for learning React, its sets up your development environment and provides a nice developer experience. It will create a live development server, use Webpack to automatically compile React, JSX, and ES6, and use ESLint to test and warn about mistakes in the code. You will need to have Node Js on your machine. &lt;a href="https://nodejs.org"&gt;For a guide on how to download and install node, visit the official documentation&lt;/a&gt;&lt;br&gt;
After this you can create a project by running the following code in the terminal;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run this command, a new windows will pop up at &lt;code&gt;localhost:3000&lt;/code&gt; with the React' welcome page&lt;/p&gt;

&lt;h2&gt;
  
  
  React Components
&lt;/h2&gt;

&lt;p&gt;So let's move on to creating a component in React, remember at the introduction we mentioned that with React we build interfaces by dividing the UI into a collection of components.&lt;br&gt;
The &lt;code&gt;create-react-app&lt;/code&gt; comes with a lot of files that perform various functions. If you look into the project structure, you will find a &lt;code&gt;/public&lt;/code&gt; and &lt;code&gt;/src&lt;/code&gt; directories along with some other files. The &lt;code&gt;/src&lt;/code&gt; directory is where we will be writing all our React code.&lt;br&gt;
The &lt;code&gt;/src/App.js&lt;/code&gt; is the most important of all the files you have there, every other component you would be creating would be rendered in the &lt;code&gt;App.js&lt;/code&gt; component.&lt;br&gt;
So let us start by analyzing our first component &lt;code&gt;/src/App.js&lt;/code&gt; which I have simplified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class App extends React.Component {
  render() {
    return (
      &amp;lt;div className="App"&amp;gt;
        &amp;lt;h1&amp;gt;Hello, React!&amp;lt;/h1&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}

export default App
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see from the above that we imported a JavaScript library( the react npm paackage) and we have a class that returns a heading of "Hello, React" then we exported the function App. When we open our browser now, we would only be seeing our 'Hello, React'. &lt;br&gt;
We can have more than one component and render them in our &lt;code&gt;App.js&lt;/code&gt; component.&lt;br&gt;
Take for example&lt;br&gt;
We have a Header component in &lt;code&gt;/src/Header.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class Header extends React.Component {
  render() {
    return (
      &amp;lt;div className="header"&amp;gt;
          &amp;lt;h1&amp;gt;This is a header&amp;lt;/h1&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}

export default Header
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we have another component Content in &lt;code&gt;/src/Content.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'

class Content extends React.Component {
  render() {
    return (
      &amp;lt;div className="content"&amp;gt;
          &amp;lt;p&amp;gt;This is the content of the page&amp;lt;/p&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}

export default Content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can now render both component in our App component &lt;code&gt;/src/App.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import Header from './Header'
import Content from './Content'

class App extends React.Component {
  render() {
    return (
      &amp;lt;div className="app"&amp;gt;
          &amp;lt;Header /&amp;gt;
          &amp;lt;Content /&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}

export default App
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that we have imported both our Header component and Content component and rendered them in our App component.&lt;/p&gt;

&lt;h2&gt;
  
  
  JSX
&lt;/h2&gt;

&lt;p&gt;JSX (or JavaScript XML) is a special language we use to build component's output, it looks like HTML but it has some JavaScript embedded into it.&lt;br&gt;
Take a look at the App function in the original example (the one we had after running create-react-app), it returns something that at first sight looks quite strange&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import logo from './logo.svg';
import './App.css';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
        &amp;lt;p&amp;gt;
          Edit &amp;lt;code&amp;gt;src/App.js&amp;lt;/code&amp;gt; and save to reload.
        &amp;lt;/p&amp;gt;
        &amp;lt;a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        &amp;gt;
          Learn React
        &amp;lt;/a&amp;gt;
      &amp;lt;/header&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the above, we see that everything inside of the return statement is JSX. JSX is actually closer to JavaScript, not HTML, so there are a few key differences to note when writing it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use &lt;code&gt;className&lt;/code&gt; instead of &lt;code&gt;class&lt;/code&gt; for adding a CSS class because class is a keyword in JavaScript &lt;/li&gt;
&lt;li&gt;Self closing tags must end with a slash e.g &lt;code&gt;&amp;lt;img /&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Methods and properties in JSX are written in camelCase e.g &lt;code&gt;onsubmit&lt;/code&gt; will become &lt;code&gt;onSubmit&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;JavaScript expressions can also be embedded inside JSX using curly braces, including variables, functions, and properties for example,
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = 'Martha'
const greeting= &amp;lt;h1&amp;gt;Hello, {name}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;This article covers the very basic introduction to React, there is still so much more you will need to learn, I hope you push further and get a mastery of React. Feel free to drop a comment on any topic you would like me to write about and stay tuned for more articles on React from me😊&lt;/p&gt;

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