Watts Kendall

Watts Kendall

1563239959

How to Build a Reusable React Login Component

Learn how to build a reusable and shareable Firebase Google login component

In this chapter, we will continue from where we left off in the first chapter that dealt with implementing a Facebook login and initiating a react app structure. We are going to add Google login to the same app we created in the first chapter. This chapter is short, sweet, and simple because we have already completed the problematic section in the previous chapter. We have broken down this tutorial into various sub-headings for you to grasp the concept about React project, Google login, firebase auth, component implementation, etc. and work accordingly.

Now, let’s get on with implementing the Google login!

What you’ll learn …?

  • How to create a new React app.
  • How to pass props in React.
  • How to use Firebase Authentication.
  • How to create and set up a Google app.
  • How to use Bit.

Most of the points have already been covered in the first chapter, so this chapter makes the concepts even clearer as we move along.

Problem

As we have done most of the problematic section in the first chapter, this chapter only tackles the issue of implementation of Google login; which is relatively simple compared to Facebook login. So, we need a quick win here without wasting much of our time. We need to generate result quickly, which is an important part that keeps us motivated to reach our end milestones.

Requirements

Here’s a complete list of plugins, packages, and services we’re going to need to gain something from this tutorial:

  • Nodejs v8.x.x or higher installed along with NPM/yarn.
  • Firebase and Bit account.
  • You’ve already completed the project from the previous chapter.
  • Firebase and Bit package.

Reusable previous code

To make things easier for us, we are going to replicate the Facebook component that we created in the first chapter and change all related names to Google. The project directory structure will look something like below:

The places where we changed the name from Facebook to Google are mentioned in detail below:

  1. Folder FacebookAuth is changed to GoogleAuth.
  2. FacebookAuth.jsx file is changed to GoogleAuth.jsx file.
  3. In GoogleAuth.jsx file, change the class name to GoogleAuth.
  4. In handleLogin() function, change the FacebookAuthProvider to GoogleAuthProvider.

Then, we need to change Facebook to Google in the HTML section as given below in the following code snippet:

<li class="firebaseui-list-item">
     <button
        onClick={this.handleLogin}
        class="firebaseui-idp-button mdl-button mdl-js-button mdl-button--raised firebaseui-idp- **google** firebaseui-id-idp-button">
         <span class="firebaseui-idp-icon-wrapper">

           <img class="firebaseui-idp-icon" alt="" src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/ **google**.svg">
          </span>
          <span class="firebaseui-idp-text firebaseui-idp-text-long">
              Sign in with **Google**
          </span>
          <span class="firebaseui-idp-text firebaseui-idp-text-short">
**Google**
          </span>
      </button>

The above code will provide us with the Google login component which we need to import in our App.js file.

Now, we need to copy the code below and add it to our App.js file.

In our GoogleAuth/index.js file, we need to replace all the import of FacebookAuth with GoogleAuth, as shown in the code snippet below:

Now, every change will be made only in our App.js file. We need to change the App.js file to include the component and pass firebase configuration as shown in the code snippet below:

As a result, we will see the following result in our browser screen or app screen:

We can see that this is working fine. Now, we move one to Firebase part of our tutorial chapter.

Activating the Sign-in method in Firebase

In this step, we need to activate the Sign-in method in our firebase console for Google login to work. For that, we need to:

Go to firebase console > Authentication > enable Google Sign-in Method

Lastly, we need to provide a project support email and then click on “save” button as shown in the console screenshot below:

After this is done, we need to return to our app and click on Google Login. We will see the following simulation and result in our browser console:

Finally, we have successfully implemented Google login as well in our react app.

Now, we need to push the code to Bit as in the previous chapter by creating a new collection.

Make it Reusable and Sharable with Bit

To make our code reusable and shareable, we’ll do some restructuring and move all our code to ‘components’ (this is not mandatory but a better practice, when using Bit). Then, we’ll export it (with all its dependencies), to a component collection on Bit’s cloud, to be shared with others and easily reused.

In this step, we are going to push the new component i.e. Google login component to Bit again. We already have our Bit package installed and connected to our Bit account. So, we need to create a collection and start by tracking the component.

Note: The first and second step features an installation of Bit account. These steps can be skipped if you already have a Bit account.

1. Create a collection and initialize Bit on a project

Here, we create a new collection on Bit to which we are going to push all our component code. We use the Bit “create collection” configuration page to create a new collection named “firebase-auth-collection” as shown in the screenshot below:

To successfully push the whole project to Bit, you need to follow the instructions given on the page shown below:

First, we need to install Bit CLI

Using NPM,> npm install bit-bin --global
Then, we need to go to the project directory in our Bit CLI and perform the commands bit init and run bit login on Bit CLI as shown in the screenshot below:

2. Configure a React compiler for our component

When we configure a compiler we tell Bit to capsule the component with it. Capsuling components together with their compilers gives us the freedom to use, build and test them anywhere. This includes being able to run the code in any of the applications we’d like to use the component in, as well as running it in the cloud to enable features such as the live component playground.

bit import bit.envs/compilers/react --compiler

3. Track components

We need to track our component by using the following command in your command prompt or Bit console:

bit add src/components/GoogleAuth

The result after the command is performed is shown below in the screenshot:

4. Tag and export to our collection on Bit’s cloud

Here, we are going to set a version to all tracked components, and export to this collection using following bit command:

bit tag --all 1.0.0

Finally, we need to perform following bit command to push our component code to bit collection that we created before:

bit export krissnawat.firebase-auth-collection

Now, our package is live on Bit. It is our second component in our firebase auth collection as shown in the screenshot below:

Lastly, we need to replace the component in our App.js file as shown in the code snippet below:

import React, { Component } from "react";
	// import "./App.css";
	import "./index.css";
	import FacebookAuth from "@bit/krissnawat.firebase-auth-collection.facebook-auth";
	import GoogleAuth from "./components/GoogleAuth";
	

	const firebaseConfig = {
	  apiKey: "xxxxxxxx",
	  authDomain: "xxxxxx.firebaseapp.com",
	  databaseURL: "https://xxxxxxx.firebaseio.com",
	  projectId: "xxxxxxx",
	  storageBucket: "xxxxxxx.appspot.com",
	  messagingSenderId: "xxxxxxx",
	  appId: "1:140177169073:web:xxxxxxx"
	};
	class App extends Component {
	  render() {
	    return (
	      <div className="App">
	        <FacebookAuth firebaseConfig={firebaseConfig} />
	        <GoogleAuth firebaseConfig={firebaseConfig} />
	      </div>
	    );
	  }
	}
	

	export default App;

Finally, the implementation of Google login with firebase auth and uploading the component to Bit is complete. Now, we can run the project locally to test everything.

Conclusion

In this tutorial, we learned how to implement Google login with firebase. We also learned about implementing the re-usable code in the form of components as in the previous chapter. Finally, we were successful in pushing our second component in our Firebase Auth collection.

Thanks for reading. If you liked this post, share it with all of your programming buddies!

Further reading

Understanding TypeScript

Typescript Masterclass & FREE E-Book

React - The Complete Guide (incl Hooks, React Router, Redux)

Modern React with Redux [2019 Update]

The Complete React Developer Course (w/ Hooks and Redux)

React JS Web Development - The Essentials Bootcamp

React JS, Angular & Vue JS - Quickstart & Comparison

The Complete React Js & Redux Course - Build Modern Web Apps

React JS and Redux Bootcamp - Master React Web Development

Using React-Router to Optimize Single Page Applications

#reactjs #react-native #javascript #web-development

What is GEEK

Buddha Community

How to Build a Reusable React Login Component
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

I am Developer

1626836644

React Google Login Example

Integrate google login in react apps; This example tutorial will show you step by step how to implement google login in react apps using javascript SDK.

If you want to integrate google login authentication in your react app. So you will not need any react plugin for this. In this tutorial, you will learn how to add a google login button in react app without any react plugin.

Before you can integrate Google Sign-In into your react app, you must create a client ID, which you need to call the sign-in API.

To create a Google API Console project and client ID, go to the APIs & Services dashboard and then follow the following steps:

Step 1: Visit Google Developer Console. And create a new project as following in below picture:

Step 2: you will see the screen looks like, show here you can set your project name as you want.

Step 3: Now you have successfully created a new project. After that, you need to select the created projects on the top menu. Then click on OAuth consent screen and select the given option according to your requirement:

Step 4: when you will be done above. After that automatically appear below given screen. In this screen, you need to fill your website URL, privacy policy URL, etc.

Step 5: you need to click on left side menu credentials and appear below screen. In this screen, you need to select OAuth client ID.

Step 6: After that, the below form will be apper. Here From different Application type options, you have to select Web application. Once you have select Web application option, then one form will appear on web page. Here you have to define Name and you have also define Authorized redirect URIs field and lastly click on Create button.

Step 7: the pop looks like below in picture automatically appear. Once you have click on the create button, then you can get your Client ID and your client secret key. You have to copy both key for future use for implement Login using Google account using PHP.

Please note that, google client id and secret.

How to Add Google Login to your React Apps

  • Step 1 - Create React App
  • Step 2 - Install Bootstrap 4 Library
  • Step 3 - Create Google Login Component
  • Step 4 - Import Google Login Component in App.js

https://www.tutsmake.com/react-google-login-button-example/

#react-google-login component #react-google-login demo #google login with react #add google login button to react

Aubrey  Price

Aubrey Price

1589722410

Build a simple React Native Pokemon app with React-Navigation

As we start learning new technologies we want to start building something or work on a simple project to get a better understanding of the technology. So, let’s build this simple app.
For this app, we will be using PokeApi to get our pokemon data, and also we will be using Hooks. I am using pokemondb for pokemon sprites. It’s just a personal preference you can use whatever you want.

#react-native #react-native-app #react-navigation #react-native-development #react

Mathew Rini

1615544450

How to Select and Hire the Best React JS and React Native Developers?

Since March 2020 reached 556 million monthly downloads have increased, It shows that React JS has been steadily growing. React.js also provides a desirable amount of pliancy and efficiency for developing innovative solutions with interactive user interfaces. It’s no surprise that an increasing number of businesses are adopting this technology. How do you select and recruit React.js developers who will propel your project forward? How much does a React developer make? We’ll bring you here all the details you need.

What is React.js?

Facebook built and maintains React.js, an open-source JavaScript library for designing development tools. React.js is used to create single-page applications (SPAs) that can be used in conjunction with React Native to develop native cross-platform apps.

React vs React Native

  • React Native is a platform that uses a collection of mobile-specific components provided by the React kit, while React.js is a JavaScript-based library.
  • React.js and React Native have similar syntax and workflows, but their implementation is quite different.
  • React Native is designed to create native mobile apps that are distinct from those created in Objective-C or Java. React, on the other hand, can be used to develop web apps, hybrid and mobile & desktop applications.
  • React Native, in essence, takes the same conceptual UI cornerstones as standard iOS and Android apps and assembles them using React.js syntax to create a rich mobile experience.

What is the Average React Developer Salary?

In the United States, the average React developer salary is $94,205 a year, or $30-$48 per hour, This is one of the highest among JavaScript developers. The starting salary for junior React.js developers is $60,510 per year, rising to $112,480 for senior roles.

* React.js Developer Salary by Country

  • United States- $120,000
  • Canada - $110,000
  • United Kingdom - $71,820
  • The Netherlands $49,095
  • Spain - $35,423.00
  • France - $44,284
  • Ukraine - $28,990
  • India - $9,843
  • Sweden - $55,173
  • Singapore - $43,801

In context of software developer wage rates, the United States continues to lead. In high-tech cities like San Francisco and New York, average React developer salaries will hit $98K and $114per year, overall.

However, the need for React.js and React Native developer is outpacing local labour markets. As a result, many businesses have difficulty locating and recruiting them locally.

It’s no surprise that for US and European companies looking for professional and budget engineers, offshore regions like India are becoming especially interesting. This area has a large number of app development companies, a good rate with quality, and a good pool of React.js front-end developers.

As per Linkedin, the country’s IT industry employs over a million React specialists. Furthermore, for the same or less money than hiring a React.js programmer locally, you may recruit someone with much expertise and a broader technical stack.

How to Hire React.js Developers?

  • Conduct thorough candidate research, including portfolios and areas of expertise.
  • Before you sit down with your interviewing panel, do some homework.
  • Examine the final outcome and hire the ideal candidate.

Why is React.js Popular?

React is a very strong framework. React.js makes use of a powerful synchronization method known as Virtual DOM, which compares the current page architecture to the expected page architecture and updates the appropriate components as long as the user input.

React is scalable. it utilises a single language, For server-client side, and mobile platform.

React is steady.React.js is completely adaptable, which means it seldom, if ever, updates the user interface. This enables legacy projects to be updated to the most new edition of React.js without having to change the codebase or make a few small changes.

React is adaptable. It can be conveniently paired with various state administrators (e.g., Redux, Flux, Alt or Reflux) and can be used to implement a number of architectural patterns.

Is there a market for React.js programmers?
The need for React.js developers is rising at an unparalleled rate. React.js is currently used by over one million websites around the world. React is used by Fortune 400+ businesses and popular companies such as Facebook, Twitter, Glassdoor and Cloudflare.

Final thoughts:

As you’ve seen, locating and Hire React js Developer and Hire React Native developer is a difficult challenge. You will have less challenges selecting the correct fit for your projects if you identify growing offshore locations (e.g. India) and take into consideration the details above.

If you want to make this process easier, You can visit our website for more, or else to write a email, we’ll help you to finding top rated React.js and React Native developers easier and with strives to create this operation

#hire-react-js-developer #hire-react-native-developer #react #react-native #react-js #hire-react-js-programmer

Kaustav Hazra

1603479480

 Component Life Cycle in React

Every component in React goes through a lifecycle of events. You can think is of going through a cycle of birth, growth, and death the same as the picture below.

The phases are:

  • Initialization — Starting the journey of your component
  • Mounting — Birth of your component
  • Update — Growth of your component
  • Unmount — Death of your component

1. Initialization

This is the phase in which the component is going to start its journey. The developer has to define the props and initial state of the component. This is usually done inside the constructor method (see below to understand the initialization phase better).

#react #react-lifecycle-method #react-course #react-for-beginner #react-js-tutorials