create account

Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1) by pckurdu

View this thread on: hive.blogpeakd.comecency.com
· @pckurdu ·
$22.95
Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)
![react-redux.fw.png](https://cdn.steemitimages.com/DQmRpmFiQxCwe4jswNSCADhUgLnyH8Ce249cszhzrYXLGvC/react-redux.fw.png)
<br>
# Repository

### React
https://github.com/facebook/react

### Material-ui
https://github.com/mui-org/material-ui

### My Github Address
https://github.com/pckurdu

### This Project Github Address
https://github.com/pckurdu/Build-A-Blog-Site-With-React-Redux-Firebase-And-MaterializeCSS-Part-1

# What Will I Learn?

- You will learn to create a `react project`.
- You will learn the logic of `BrowserRouter` concept.
- You will learn the `Link` and `NavLink` modules in the react router.
- You will learn how to create `navbar` with materializecss.
- You will learn the sub-component router in the react.
- You will learn how to create react component functions.

# Requirements

- text editor (I used visual studio code editor)
- Basic javascript information
- Basic react information

# Difficulty

- Basic

# Tutorial Contents
Hello to everyone,

We're starting a new tutorial series.In this tutorial series we will develop the react application.We will build the `redux` structure to better manage state objects that are complex when developing the react application.Thus we will learn to use redux on the react.

We will perform authentication settings and data storage for our application using `firebase`. We will also review and use cloud functions to instantly show other users' shares to other users.

We will doall the design of the application using `materializecss`.At the end of this tutorial series, we will examine all the fine details of materializecss.

Here are the topics in this tutorial:

- Create React Project
- Create Navbar Component
- Create SignInLinks Component
- Create SignOutLinks Component

Let’s start

### Create React Project

When creating a project, it is very important to configure the project. When we configure this blog site, we need to set up what we want to do. Otherwise it will become more complex as the project progresses, and perhaps not be able to complete the project.

The most logical and shortest way to create a react project is to use the `create-react-app`.With the create-react-app, we can build all essential components for reacting in a short time.

At the command line, we write the following command to the location where we will create the project.
```
create-react-app react-blog
```
<br>
Thus our react project is created.

We run the project with the `yarn start` command and we get the following image.
![react1.png](https://cdn.steemitimages.com/DQmQnXrden2M2WYmcsDar5XbA1ZvzBUwDP9xk6GrgLvbpu1/react1.png)
<br>
Since we have created the react project in this way, it is contained in a number of unnecessary files. We can delete these junk files if we want, but the `App.js` file to resolve the confusion of meaning, let's do as follows.
```
import React, { Component } from 'react';

class App extends Component {
  render() {
    return (
        <div>
        <h1>Blog Site</h1>
        </div>
    );
  }
}

export default App;
```
<br>
The following image occurs when we do so.
![react2.png](https://cdn.steemitimages.com/DQmf9L97xxxjcRQaYdVh2ixkUtpYRXstFRdC62MVDw4QWyw/react2.png)
<br>
We will use materialize to design the pages of our project. We can import `materializecss cdn` after editing the pages. If we place the following cdn in the head field on the `public / index.html` page, we can use the materialize codes in our project.
```
<!--Import Google Icon Font-->
     <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
     <!--Import materialize.css-->
     <link type="text/css" rel="stylesheet" href="css/materialize.min.css"  media="screen,projection"/>
```
<br>
We can start to create the files of our project.

Our project will perform verification procedures and write data and get data from the firebase firestore. The created projects will enter users in detail and a list of projects in other users will be displayed. Users will be able to see the details by clicking on the project summary.

We'll add an unchanged layout page on a changed page. This layout page will contain links that users will see after logging in and without logging in.

With the logic that we create, let us create the `components` folder in the `src` folder.

Let us create `auth`, `dashboard`, `layout` and `Project` folders under the components folder.

Since the auth folder will perform authentication operations, it must host login and sign up components. So create the `signIn.js` and `signUp.js` files in the auth folder.

The dashboard page is the page you should see after logging in. List of projects and announcements should be included. We add the `Dashboard.js` and `Notification.js` files to the dashboard folder.

The navbar that we created in the Layout folder should be included. Since the `signedInLinks.js` and `signedOutLinks.js` files will be included in the navbar component, they must be included in these files in the layout folder.

In the project folder, the user will create the project and because these projects will be listed, the `CreateProject.js`, `ProjectDetails.js`, `ProjectList.js`, and `ProjectSummary.js` files should be included.

After creating all the files, components will be created as follows.
![react3.png](https://cdn.steemitimages.com/DQmSDzZ2eoMgN3kU2TA6BT4btdXo8wCNeoWWhrs1yERFWmh/react3.png)
<br>
Finally, we can form the basis of the router structure to provide link redirection. We need to download `react-router-dom` files to use a router in the react.

We can download the command line if we write the `yarn add react-router-dom`.

We'll get the app component as the base, so we need to write the routing codes here.
```
//Import the routing module.
import {BrowserRouter} from 'react-router-dom';

class App extends Component {
  render() {
    return (
      //other components must be included in the BrowserRouter component
      <BrowserRouter>
        <div className="App">
        <h1>Blog Site</h1>
        </div>
      </BrowserRouter>
    );
  }
}
```
<br>
### Create Navbar Component

Navbar is a structure that contains links to the page. We will keep the links to routing on our navbar.

We only need to use the `nav-wrapper` class because we use `materializeCSS` to create a navbar.

We can create the navbar component by creating the navbar function in the `navbar.js` file.
```
import React from 'react';
//to perform routing
import {Link} from 'react-router-dom';

const Navbar=()=>{
    return(
        //navbar forming class
        <nav className="nav-wrapper light-blue lighten-2">
            <div className="container">
                <Link to='/' className="brand-logo">Project Blog</Link>
            </div>
        </nav>
    )
}

export default Navbar
```
<br>
We need to use this componenti `App component`.
```
//Let's import the navbar function in the file
import Navbar from './components/layout/Navbar';
…
<BrowserRouter>
        <div className="App">
        <Navbar />
        </div>
      </BrowserRouter>
```
<br>
So we created our navbar. Since we will do the forwarding process here and we define it in the App component, the `Navbar` component will appear on all pages.
![react4.png](https://cdn.steemitimages.com/DQmbfaPg4dLJmMEYKCQoMGwe4gc7aWqUqJMvoc5ehoemsB1/react4.png)
<br>
### Create SignInLinks Component

In this section we will define the links that the user will see when they log in. We have already defined the `signInLinks.js` file. We will call this file in the `Navbar.js` file so the links will be visible on the navbar.

#### Navbar.js
```
import SignedInLinks from './SignedInLinks';
…
//navbar forming class
        <nav className="nav-wrapper light-blue lighten-2">
            <div className="container">
                <Link to='/' className="brand-logo">Project Blog</Link>
                {/* SignedInLinks component */}
                <SignedInLinks/>
            </div>
        </nav>
```
<br>
The user must be able to produce new projects, to be able to see their profile and to exit after they have logged in. So we need to create a link in the navbar. We need to use `NavLink` when defining links with NavLink you can router in navbar.

#### SignInLinks.js
```
import React from 'react';
//to perform routing
import {NavLink} from 'react-router-dom';

const SignInLinks=()=>{
    return(
        // links to the right
        <ul className="right">
           <li><NavLink to='/'>New Project</NavLink></li>
           <li><NavLink to='/'>Log Out</NavLink></li>
           <li><NavLink to='/' className="btn btn-floating red">PK</NavLink></li>
        </ul>
    )
}

export default SignInLinks
```
<br>
![react1.gif](https://cdn.steemitimages.com/DQmNbc8JmxuETf5y5F85s86LpaC37NtNKjUKZUUUQcjWsE8/react1.gif)
<br>
### Create SignOutLinks Component

In this section, we will create links that the user will see without login. We will use NavLink to place links in the Navbar.

### SignOutLinks.js
```
import React from 'react';
//to perform routing
import {NavLink} from 'react-router-dom';

const SignOutLinks=()=>{
    return(
        <ul className="right">
           <li><NavLink to='/'>Signup</NavLink></li>
           <li><NavLink to='/'>Login</NavLink></li>
        </ul>
    )
}

export default SignOutLinks
```
<br>
The following image occurs if we use this component in the `Navbar.js` file.
```
import SignedOutLinks from './SignedOutLinks';
…
//navbar forming class
        <nav className="nav-wrapper light-blue lighten-2">
            <div className="container">
                <Link to='/' className="brand-logo">Project Blog</Link>
                <SignedInLinks/>
                <SignedOutLinks/>
            </div>
        </nav>
```
<br>
![react2.gif](https://cdn.steemitimages.com/DQmU8SLVRbbpzK1bdGvmc3tksFbERRaBZm9obb3WrCXANjE/react2.gif)
<br>
Since we don't have any firebase authentication now, all links are seen side by side. keep this for now as we will do this in the next tutorials.

See you in future tutorials

# Proof of Work Done
https://github.com/pckurdu/Build-A-Blog-Site-With-React-Redux-Firebase-And-MaterializeCSS-Part-1
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 76 others
properties (23)
authorpckurdu
permlinkbuild-a-blog-site-with-react-redux-firebase-and-materializecss-part-1
categoryutopian-io
json_metadata{"tags":["utopian-io","tutorials","react","redux","firebase"],"image":["https://cdn.steemitimages.com/DQmRpmFiQxCwe4jswNSCADhUgLnyH8Ce249cszhzrYXLGvC/react-redux.fw.png","https://cdn.steemitimages.com/DQmQnXrden2M2WYmcsDar5XbA1ZvzBUwDP9xk6GrgLvbpu1/react1.png","https://cdn.steemitimages.com/DQmf9L97xxxjcRQaYdVh2ixkUtpYRXstFRdC62MVDw4QWyw/react2.png","https://cdn.steemitimages.com/DQmSDzZ2eoMgN3kU2TA6BT4btdXo8wCNeoWWhrs1yERFWmh/react3.png","https://cdn.steemitimages.com/DQmbfaPg4dLJmMEYKCQoMGwe4gc7aWqUqJMvoc5ehoemsB1/react4.png","https://cdn.steemitimages.com/DQmNbc8JmxuETf5y5F85s86LpaC37NtNKjUKZUUUQcjWsE8/react1.gif","https://cdn.steemitimages.com/DQmU8SLVRbbpzK1bdGvmc3tksFbERRaBZm9obb3WrCXANjE/react2.gif"],"links":["https://github.com/facebook/react","https://github.com/mui-org/material-ui","https://github.com/pckurdu","https://github.com/pckurdu/Build-A-Blog-Site-With-React-Redux-Firebase-And-MaterializeCSS-Part-1"],"app":"steemit/0.1","format":"markdown"}
created2019-03-10 10:16:45
last_update2019-03-10 10:16:45
depth0
children4
last_payout2019-03-17 10:16:45
cashout_time1969-12-31 23:59:59
total_payout_value17.508 HBD
curator_payout_value5.442 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10,115
author_reputation23,385,816,696,918
root_title"Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,005,851
net_rshares32,653,549,886,339
author_curate_reward""
vote details (140)
@portugalcoin ·
$11.96
Thank you for your contribution @pckurdu.
After analyzing your tutorial we suggest the following points:

- The tutorial is well structured, but the features explained in your tutorial are very basic. In the next tutorial try to innovate the features that will explain in your contribution.

- Using GIFs to show results is definitely better than standard still images.

Looking forward to your upcoming tutorials.

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/8/2-1-3-1-1-4-2-3-).

---- 
Need help? Chat with us on [Discord](https://discord.gg/uTyJkNm).

[[utopian-moderator]](https://join.utopian.io/)
👍  , , , , , , , , , , , , , , , , ,
properties (23)
authorportugalcoin
permlinkre-pckurdu-build-a-blog-site-with-react-redux-firebase-and-materializecss-part-1-20190310t122736335z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["pckurdu"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/8/2-1-3-1-1-4-2-3-","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2019-03-10 12:27:36
last_update2019-03-10 12:27:36
depth1
children1
last_payout2019-03-17 12:27:36
cashout_time1969-12-31 23:59:59
total_payout_value9.082 HBD
curator_payout_value2.874 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length866
author_reputation599,460,589,822,571
root_title"Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,011,081
net_rshares17,004,422,487,732
author_curate_reward""
vote details (18)
@utopian-io ·
Thank you for your review, @portugalcoin! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-pckurdu-build-a-blog-site-with-react-redux-firebase-and-materializecss-part-1-20190310t122736335z-20190313t043039z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-03-13 04:30:39
last_update2019-03-13 04:30:39
depth2
children0
last_payout2019-03-20 04:30:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length64
author_reputation152,955,367,999,756
root_title"Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,195,333
net_rshares0
@steem-ua ·
#### Hi @pckurdu!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-build-a-blog-site-with-react-redux-firebase-and-materializecss-part-1-20190310t133550z
categoryutopian-io
json_metadata"{"app": "beem/0.20.18"}"
created2019-03-10 13:35:51
last_update2019-03-10 13:35:51
depth1
children0
last_payout2019-03-17 13:35:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length286
author_reputation23,214,230,978,060
root_title"Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,013,932
net_rshares0
@utopian-io ·
Hey, @pckurdu!

**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Get higher incentives and support Utopian.io!**
 Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via [SteemPlus](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-build-a-blog-site-with-react-redux-firebase-and-materializecss-part-1-20190311t020047z
categoryutopian-io
json_metadata"{"app": "beem/0.20.17"}"
created2019-03-11 02:00:48
last_update2019-03-11 02:00:48
depth1
children0
last_payout2019-03-18 02:00:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length589
author_reputation152,955,367,999,756
root_title"Build A Blog Site With React, Redux Firebase And MaterializeCSS (Part 1)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id81,043,328
net_rshares0