<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arafin on Medium]]></title>
        <description><![CDATA[Stories by Arafin on Medium]]></description>
        <link>https://medium.com/@arafin2021?source=rss-ece7e8d3f047------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DLFfslba2SnUOpCx</url>
            <title>Stories by Arafin on Medium</title>
            <link>https://medium.com/@arafin2021?source=rss-ece7e8d3f047------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:59:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arafin2021/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JavaScript Interview Question]]></title>
            <link>https://arafin2021.medium.com/javascript-interview-question-b41d1b7aecd0?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/b41d1b7aecd0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[javascript-interview]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Sat, 08 May 2021 06:02:56 GMT</pubDate>
            <atom:updated>2021-05-08T06:02:56.658Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Truthy value vs Falsy value in JavaScript</strong></p><p>Truthy values are values that evaluate to True in a boolean context. Falsy values are values that evaluate to False in a boolean context. If the value of a variable is false, null, undefined, 0, NaN, empty string then value of this variable is falsy value. Otherwise the value of this variable is truthy value. Empty arrays and empty objects are also truthy values.</p><p><strong>Null Vs Undefined, different ways you will get undefined</strong></p><p>In JavaScript, undefined is a type, whereas null an object. It means a variable declared, but no value has been assigned a value. Whereas, null in JavaScript is an assignment value. You can assign it to a variable.</p><p>Different ways of getting undefined in JavaScript are given below:</p><p>When we declare a variable without assigning value, then the value of the variable is undefined.</p><pre>let name;</pre><pre>console.log(name); // undefined</pre><p>When we declare a function without returning a value, then the function returns undefined value.</p><pre>function add(a, b) {</pre><pre>console.log(a + b);</pre><pre>}</pre><pre>const result = add(3,2);</pre><pre>console.log(result); // undefined</pre><p>If we return nothing from a function this is also undefined.</p><pre>function add(a, b) {</pre><pre>console.log(a + b);</pre><pre>return;</pre><pre>}</pre><pre>const result = add(3,2);</pre><pre>console.log(result); // undefined</pre><p>If a function have parameters but by mistake we don’t pass a parameter then the parameter value in the function is undefined.</p><pre>function add(a, b) {</pre><pre>// b is now undefined when add(2) is called</pre><pre>console.log(a + b);</pre><pre>}</pre><pre>const result = add(2);</pre><pre>console.log(result); // undefined</pre><p>When a property doesn’t exist in the object but we want to access this parameter then the result should be undefined.</p><pre>const person = {name: “Arafin”};</pre><pre>console.log(person.age); // undefined</pre><p>If we want to access a value from an array but the index doesn’t exist in this array then the result is undefined.</p><pre>let array = [1,2,3];</pre><pre>console.log(array[5]); // undefined</pre><p>If we explicitly assign undefined to a variable the value is undefined. But it’s not recommended to explicitly assign undefined value.</p><pre>let name = undefined;</pre><pre>console.log(name); // undefined</pre><p><strong>Double equal(==) vs triple equal(===)</strong></p><p><strong>==</strong> is used for comparing two variables, but it ignores the datatype of variable whereas <strong>===</strong> is used for comparing two variables, but this <strong>operator</strong> also checks datatype and compares two values. Double equal only compares the value, triple equal compares the type and value.</p><p><strong>What is Scope in JavaScript?</strong></p><p>Scope in JavaScript refers to the current context of code, which determines the accessibility of variables to JavaScript. The two types of scope are local and global: Global variables are those declared outside of a block. Local variables are those declared inside of a block.</p><p><strong>What is JavaScript Hoisting?</strong></p><p>When a variable is declared with var in JavaScript the variable is assumed as declared in the top of this function and the variable can be accessed anywhere in this function.</p><p><strong>What is closure in JavaScript?</strong></p><p>When we call a function or return a function from another function it creates a closed environment. The internal function makes a reference of the variable of the other function.</p><p><strong>Difference between call, bind and apply?</strong></p><p>If we have a method in an object but we want to use this method in another object we can use it by using call, apply or bind.</p><p>In call — parameter of the method should be comma separated.</p><p>In apply — parameter of the method should be in an array.</p><p>Call and apply the method of the object anonymously. But when we use bind the method is injected in the current object.</p><p><strong>What is window in JavaScript?</strong></p><p>The Window interface is home to a variety of functions, namespaces, objects, and constructors which are not necessarily directly associated with the concept of a user interface window. However, the Window interface is a suitable place to include these items that need to be globally available.</p><p><strong>What is this keyword in JavaScript?</strong></p><p>In JavaScript this keyword refers to the object it belongs to. It has different values depending on where it is used. In a function, this refers to the global object</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b41d1b7aecd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revision of React]]></title>
            <link>https://arafin2021.medium.com/revision-of-react-3d6e5b012e47?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d6e5b012e47</guid>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Fri, 07 May 2021 15:54:05 GMT</pubDate>
            <atom:updated>2021-05-07T15:54:05.822Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we will discuss the main features of React what you must know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d6e5b012e47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A short revision of JavaScript ES6]]></title>
            <link>https://arafin2021.medium.com/a-short-revision-of-javascript-es6-79af2859e58e?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/79af2859e58e</guid>
            <category><![CDATA[block-binding]]></category>
            <category><![CDATA[arrow-functions]]></category>
            <category><![CDATA[let-const-var]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Thu, 06 May 2021 09:41:14 GMT</pubDate>
            <atom:updated>2021-05-06T09:41:14.167Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Block Bindings</strong></p><p>In computer programming, a block or code block is a lexical structure of source code that is grouped together. A programming language that permits the creation of blocks, including blocks nested within other blocks, is called a block-structured programming language.</p><pre>function blockCode(){</pre><pre>console.log(“Block is started”);</pre><pre>//others instruction</pre><pre>}</pre><p>When a variable works on a particular block, that’s called block bindings. In JavaScript, we can declare a variable using var, let and const, var is a little bit confusing in terms of block bindings. Block-level is introduced in ES6, and then offers some best practices for using them.</p><p><strong>Var Declarations and Hoisting</strong></p><p>When a variable is declared with var, the variable is treated as declared at the top of the function. This is called var hoisting.</p><pre>function varHoisting(){</pre><pre>console.log(value); // value exist but undefined</pre><pre>if(id==23){</pre><pre>var value = 23;</pre><pre>return value;</pre><pre>} else{</pre><pre>console.log(value); // value exist but undefined</pre><pre>return null;</pre><pre>}</pre><pre>// value exist but undefined</pre><pre>}</pre><p>The code is similar as</p><pre>function varHoisting(){</pre><pre>var value;</pre><pre>if(id==23){</pre><pre>value = 23;</pre><pre>return value;</pre><pre>} else{</pre><pre>console.log(value); // value exist but undefined</pre><pre>return null;</pre><pre>}</pre><pre>// value exist but undefined</pre><pre>}</pre><p><strong>Block-Level Declarations.</strong></p><p>If we want to declare a variable in block-level and we want to stop variable hosting we need to use let keyword. If we declare a variable with let keyword the variable can only be accessed in the block where it’s declared. Outside the block the variable can not be accessed. If we want to access it will give an error.</p><pre>function blockLevel(){</pre><pre>// value does not exist</pre><pre>if(id==23){</pre><pre>let value = 23;</pre><pre>// value can only access in this block</pre><pre>return value;</pre><pre>} else{</pre><pre>// value does not exist</pre><pre>return null;</pre><pre>}</pre><pre>// value does not exist</pre><pre>}</pre><p><strong>Block Binding in Loops</strong></p><p>When we write a for loop, we want that the counter variable can not be used outside the loop. Lets see the example.</p><pre>// index can be accessed here but value is undefined</pre><pre>for (var index = 0; index &lt; 10; index++) {</pre><pre>//rest of the code</pre><pre>}</pre><pre>// index can be accessed here</pre><p>But generally we don’t want that.</p><pre>// index can not be access here</pre><pre>for (let index = 0; index &lt; 10; index++) {</pre><pre>//rest of the code</pre><pre>}</pre><pre>// index can not be access here</pre><p><strong>Global Block Bindings</strong></p><p>When we use var, we can accidently replace the global object (window in browser). That means we can overwrite an existing global using var.</p><pre>var AbortSignal = 23;</pre><pre>console.log(window.AbortSignal); // 23</pre><pre>var Animation = ‘Hi’;</pre><pre>console.log(window.Animation); // Hi</pre><p>AbortSignal, Animation are globally defined on window. It’s not safe overwriting the globally defined variables. That could cause problems</p><p>If we use let instead of var the problem is solved.</p><pre>let AbortSignal = 23;</pre><pre>console.log(window.AbortSignal === AbortSignal); //false</pre><pre>let Animation = ‘Hi’;</pre><pre>console.log(window.Animation === Animation); //false</pre><p>.</p><p><strong>Emerging Best Practices of Block Bindings</strong></p><p>If I tell you the best practices of Block bindings in one line, that should be, use const everywhere, if you need to modify the value of your variable then use let.</p><p>In a short summary if we talk about block-binding, let and const have block behavior. The variable which is declared with let and const can only be used in the block. Outside the block the variable can not be accessed which is declared with let and const. The variable which is declared with var it can be accessed anywhere in that function where it is declared.</p><p><strong>Function</strong></p><p>A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.</p><p>An example of function:</p><pre>function print(){</pre><pre>console.log(“Hello World!”);</pre><pre>}</pre><p><strong>Function with Default Parameter Values:</strong></p><pre>function sum(a, b=5){</pre><pre>return a + b;</pre><pre>}</pre><pre>console.log(sum(10, 10));//20</pre><pre>console.log(sum(10)); // 15</pre><p>The sum function has two parameters a and b. The default value of parameter b is 5. If we don’t pass any value for b, then b is assigned 5.</p><p><strong>Working with Unnamed Parameters</strong></p><p>Here is an example of unnamed parameter:</p><pre>function add(…params){</pre><pre>}</pre><pre>add(1,2,3);</pre><pre>add(1,2,3,4,5)</pre><p>We can pass as many parameter as we want in this function.</p><p>But the blow code is not okay.</p><pre>function add(…params, b){</pre><pre>}</pre><pre>add(1,2,3);</pre><pre>add(1,2,3,4,5)</pre><p>But this is okay:</p><pre>function add(b, …params){</pre><pre>}</pre><pre>add(1,2,3);</pre><pre>add(1,2,3,4,5)</pre><p><strong>Arrow Function:</strong></p><p>Arrow function is a way of writing functions in JavaScript.</p><pre>const functionName = () =&gt; {</pre><pre>//code</pre><pre>}</pre><p>When only one parameter:</p><pre>const functionName = singleParam =&gt; {</pre><pre>//code</pre><pre>}</pre><p>When more then one parameters:</p><pre>const functionName = (a, b) =&gt; {</pre><pre>//code</pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79af2859e58e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short Revision]]></title>
            <link>https://arafin2021.medium.com/short-revision-ab7cc9c4a6f1?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7cc9c4a6f1</guid>
            <category><![CDATA[mdn]]></category>
            <category><![CDATA[quick-janascript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learn-javascript]]></category>
            <category><![CDATA[revision]]></category>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Wed, 05 May 2021 11:34:21 GMT</pubDate>
            <atom:updated>2021-05-05T11:34:21.101Z</atom:updated>
            <content:encoded><![CDATA[<h3>Short Revision of JavaScript</h3><p>In this tutorial, we will discuss 10 JavaScript topics that you must know if you want to be a master in JavaScript. Let’s start now.</p><p><strong>Data Types:</strong></p><p>In computer science, a type of data type is an attribute of which tells the computer how the programmer intends to use the data. As an example age is a number type data and name is a string type data. In JavaScript, there are a total of 9 types of data.</p><p>Primitive Data types:</p><ol><li>undefined</li><li>Boolean</li><li>Number</li><li>String</li><li>Bigint</li><li>Symbol</li></ol><p>Structural Data Types:</p><ol><li>Object</li><li>Function</li></ol><p>Structural Root Primitive:</p><ol><li>null</li></ol><p><strong>Variables:</strong></p><p>A variable is a placeholder that can contain a value that could be changed. Suppose x is variable and 20 is assigned to the variable x. Now the value of x is 20. If I change the value of x 20 to 25, that is a variable. I can assign value as my wish. The value of x can be changed.</p><p>How to declare variables in JavaScript?</p><p>There are three ways to declare a variable in JavaScript.</p><pre><strong>var variableName = value;</strong></pre><pre><strong>const variableName = value;</strong></pre><pre><strong>let variableName = value;</strong></pre><pre><strong>For example, var age = 23;</strong></pre><pre><strong>let name = “Arafin”;</strong></pre><pre><strong>const ID = 34;</strong></pre><p>Difference between var, let and const?</p><p>var is globally scoped. If a var variable is declared in a program it can be accessed anywhere in the program.</p><p>let is a scoped variable. If a let variable is declared in a scope it can not be accessed outside the scope.</p><p>const is similar as let but the value of const variable can not be changed.</p><p><strong>Operators:</strong></p><p>JavaScripts operators are +(plus), -(minus), *(multiplication), /(division), %(modulus or remainder).</p><pre>var x = 25;</pre><pre>var y = 30;</pre><pre>var sum = x + y; // sum is 55</pre><p>JavaScript has a shorthand operator.</p><pre>let x = 5;</pre><pre>x = x + 3;</pre><p>We can do this in another process.</p><pre>x += 3;</pre><p>We can add two strings together in javascript.</p><pre>var res = “Arafin” + “Ahmed”; //”ArafinAhmed”</pre><pre>var ans = 2 + 3 ; // ans is a number</pre><pre>ans = 2 + 3 + “” // ans is a string</pre><p><strong>Conditions:</strong></p><p>We can check conditions in JavaScript. The structure of a check a condition in JavaScrip</p><pre>if(condition){</pre><pre>//if the condition is true the code in this block will execute.</pre><pre>}</pre><pre>var x = 5;</pre><pre>if(x===5){</pre><pre>console.log(“x is 5”);</pre><pre>}</pre><pre>else if(x===6){</pre><pre>console.log(“x is 6”);</pre><pre>}</pre><pre>else{</pre><pre>console.log(“x is not 5 or 6”);</pre><pre>}</pre><p><strong>For loop:</strong></p><p>In computer science, a loop is a programming structure that repeats a sequence of instructions until a specific condition is met.</p><p>For loop structure:</p><pre>for(initail_expression; condition; increment_expression){</pre><pre>statements….</pre><pre>}</pre><pre>Example of a for loop:</pre><pre>for(let i = 0; i&lt;10; i++) {</pre><pre>console.log(“Hello World”);</pre><pre>}</pre><p><strong>While loop:</strong></p><p>The structure of while loop:</p><pre>while(condition){</pre><pre>//statements</pre><pre>}</pre><pre>Example:</pre><pre>var i = 0;</pre><pre>while(i&lt;10){</pre><pre>console.log(“Hello World”);</pre><pre>i++;</pre><pre>}</pre><p><strong>Do while loop:</strong></p><p>The structure of do while loop:</p><pre>do {</pre><pre>//statements</pre><pre>}</pre><pre>while(condition);</pre><pre>Example:</pre><pre>var i = 0;</pre><pre>do {</pre><pre>console.log(“Hello World”);</pre><pre>}</pre><pre>while(i&lt;10);</pre><p><strong>Difference between while and do while loop:</strong></p><p>The main difference between while and do loop is, in while loop before executing the first loop iteration the condition check first, but in do while loop before first iteration no condition check. That means do while is guaranteed to execute once but in while loop it’s not guaranteed of its execution.</p><p><strong>Strings:</strong></p><p>A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. Some of the popular string methods are given below.</p><p>charAt — return the character in specific position</p><pre>let text = “Bangladesh is a beautiful country”;</pre><pre>let c = text.charAt(0); // c is B</pre><p>concat — join two string together</p><pre>let str1 = “Arafin”;</pre><pre>let str2 = “Ahmed”;</pre><pre>let res = str1.concat(str2); // res is “ArafinAhmed”</pre><p>toLowercase — make the string in lower case</p><pre>let text = “Bangladesh is a beautiful country”;</pre><pre>text.toLowercase(); // return “bangladesh is a beautiful country”</pre><p>toUppercase — make the string in uppercase</p><p>split — make a string split and return as an array</p><p>slice — make slice of a string in given position</p><p><strong>Array:</strong></p><p>An array is a data structure that contains a group of elements.</p><p>Create an array:</p><pre>let myArray = [1,2,3];</pre><p>Accessing element of an array:</p><pre>let first = myArray[0]; // array index starts from zero</pre><pre>let second = myArray[1];</pre><p>Insert new item to array:</p><pre>myArray.push(23); // 1, 2, 3, 23</pre><p>Length of array.</p><pre>let len = myArray.Length;// size of the array</pre><p>Remove item from an array:</p><pre>myArray.pop(); // remove the last element</pre><p>Remove the first item:</p><pre>myArray.shift();</pre><p><strong>Object</strong>:</p><p>Object is data type in JavaScript. We can keep data by using key value pairs in objects.</p><p>Create an object:</p><pre>const person = {}; // empty object created</pre><pre>person.name = “Arafin Ahmed”;</pre><pre>person.age = 23;</pre><p>We can access this using person.name or person[“name”];</p><p>Another example of object:</p><pre>const person = {</pre><pre>    Name: “Arafin”,</pre><pre>    Age : 23,</pre><pre>    Subjects : [“bangle”, “english”],</pre><pre>    Address: {</pre><pre>        City: “Dhaka”,</pre><pre>        Country: “Bangladesh”</pre><pre>    }</pre><pre>}</pre><p>We can put a object in a object and also we can put a array in a object.</p><p><strong>Function:</strong></p><p>Function is a block of organized reusable code. A function is created to do a specific task. When I need to do the task I can call the function and the task is easily executed. We can pass parameters in a function.</p><p>Structure of a function in JavaScript:</p><pre>//parameter is optional</pre><pre>function functionName(parameter){</pre><pre>// statement</pre><pre>}</pre><pre>Example</pre><pre>function add(a, b){</pre><pre>return a + b;</pre><pre>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7cc9c4a6f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase Google Authentication in React Web Project]]></title>
            <link>https://arafin2021.medium.com/firebase-google-authentication-in-react-web-project-d5172a9d8d30?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5172a9d8d30</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[firebaseauth]]></category>
            <category><![CDATA[google-auth]]></category>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Tue, 24 Mar 2020 03:01:22 GMT</pubDate>
            <atom:updated>2020-03-24T03:01:22.125Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Firebase?</strong><br>Firebase is a mobile and web application development platform developed by Firebase, Inc. in 2011, then acquired by Google in 2014. As of March 2020, the Firebase platform has 19 products, which are used more than 1.5 million apps including 9GAG. (According to Wikipedia)</p><p><strong>What can we do with Firebase?</strong><br> We can use firebase for Authentication.<br> We can use firebase for our application Database.<br> We can host our mobile or web application in firebase.</p><p>Let’s start simple Google Authentication by using firebase Authentication:</p><ol><li>Go to <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a></li><li>Click on Add Project and create a new project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiRn5ar2t4c3EjbZS9GXfQ.png" /></figure><p>3. Open your project and click on the web icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mwuFZKtGmQCMXbcs8gIfQ.png" /></figure><p>4. Register your web app and continue to console</p><p>5. Now Create a new react project or open your existing react project.</p><p>6. Install the Firebase JavaScript SDK:</p><pre>nmp init</pre><pre>npm install --save firebase</pre><p>7. Import module to connect with firebase :</p><pre>import * as firebase from &quot;firebase/app&quot;;</pre><pre>import &quot;firebase/auth&quot;;</pre><p>8. Initialize Firebase in your app:</p><pre>const firebaseConfig = {<br><br>  // You wil find the code from your firebase project.</pre><pre>//Click setting. General sub section (bottom the page) select config to find it</pre><pre>//Replace this with your code</pre><pre>apiKey: &quot;<strong><em>api-key</em></strong>&quot;,<br><br>  authDomain: &quot;<strong><em>project-id</em></strong>.firebaseapp.com&quot;,<br><br>  databaseURL: &quot;https://<strong><em>project-id</em></strong>.firebaseio.com&quot;,<br><br>  projectId: &quot;<strong><em>project-id</em></strong>&quot;,<br><br>  storageBucket: &quot;<strong><em>project-id</em></strong>.appspot.com&quot;,<br><br>  messagingSenderId: &quot;<strong><em>sender-id</em></strong>&quot;,<br><br>  appId: &quot;<strong><em>app-id</em></strong>&quot;,<br><br>  measurementId: &quot;G-<strong><em>measurement-id</em></strong>&quot;,</pre><pre>};<br><br><br><br>// Initialize Firebase<br><br>firebase.initializeApp(firebaseConfig);</pre><p><em>Now we are connected to firebase.</em></p><ol><li>For using authentication feature go your project in firebase and click on Authentication</li><li>Click on sign method sub section</li><li>From sign in provider enable Google sign in option</li></ol><p><em>Let’s make a function for google sign in:</em></p><ol><li>In this function create an instance of the Google provider object</li></ol><pre>const provider = new firebase.auth.GoogleAuthProvider();</pre><p>2. then call it firebase.auth().signInWithPopup(provider) <em>this signInWithPopup will give a response.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*mcTaEMoatREquPX4V_f0Pw.png" /></figure><p>Now when we call this function we can log in to our system.</p><pre>&lt;button onClick={signInWithGoogle}&gt;Signin With Google&lt;/button&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5172a9d8d30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Context API for Extreme Noobs]]></title>
            <link>https://arafin2021.medium.com/react-context-api-for-extreme-noobs-c74236e6235c?source=rss-ece7e8d3f047------2</link>
            <guid isPermaLink="false">https://medium.com/p/c74236e6235c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-context]]></category>
            <category><![CDATA[react-context-api]]></category>
            <dc:creator><![CDATA[Arafin]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 23:47:09 GMT</pubDate>
            <atom:updated>2020-03-23T23:47:09.145Z</atom:updated>
            <content:encoded><![CDATA[<p>In react we generally send data to from parent to children component. A tree is always maintained for passing data. We can not pass data anywhere we want in react.</p><p>But sometimes we can need some property that must be to all components of my react project. We can solve this problem by using React Context. I hope you know about local variable and global variable. Local variable can be used in a certain block and global variable can be used everywhere in the problem. React Context is like as global variable. Anywhere in the project we can this property.</p><p>We can also compare it to group chat. In group chat if you send a message all members of the group can see the message.</p><p><strong><em>Easy steps for using React Context in your project:</em></strong></p><p><em>First of all create your react app or open your existing react app.</em></p><p><em>Create a new component which you want to pass.</em></p><ol><li>Make a function(example ContextAPI) which you want pass, Export it as default and return something which you want to pass through the all components you want.</li></ol><pre>const ContextAPI = () =&gt; {</pre><pre>    const add = (num1, num2) =&gt;{</pre><pre>    return num1+num2;</pre><pre>}</pre><pre>    return {</pre><pre>       add</pre><pre>    }</pre><pre>}</pre><pre>export default ContextAPI;</pre><p><em>N.B. The add function will be pass</em></p><p>2. Import createContext from ‘react’</p><pre>import React, { createContext } from &#39;react&#39;;</pre><p>3. Create a Contextvariable by calling createContext()</p><pre>const ContextVariable = createContext();</pre><p>4. Make a function ContextVariableProvider and export this function.</p><p>5. In ContextVariableProvider function the parameter of the function is props. Make a variable(context) by calling your function (Context API) and return &lt;ContextVariable.provider value={context}&gt; {props.children}&lt;/ContextVariable.provider&gt;</p><pre>export const ContextVariableProvider = (props) =&gt; {</pre><pre>    const context = ContextAPI();</pre><pre>    return &lt;ContextVariable.Provider value={context}&gt;  {props.children}&lt;/ContextVariable.Provider&gt;</pre><pre>}</pre><p>Now you are ready to pass your add function to anywhere in project.</p><p><strong><em>Extreme noob steps for passing this Context API for any component:</em></strong></p><ol><li>You need to call &lt;ContextVariableProvider&gt;……….. &lt;/ContextVariableProvider&gt;<em> (Between them other components will pass, we will call it in App.js) <br>N.B. It is necessary to import </em>ContextVariableProvider</li></ol><pre>&lt;ContextVariableProvider&gt;</pre><pre>    &lt;Router&gt;</pre><pre>        &lt;Switch&gt;</pre><pre>            &lt;Route path=&quot;/component1&quot;&gt;</pre><pre>                &lt;Component1&gt;&lt;/Component1&gt;</pre><pre>            &lt;/Route&gt;</pre><pre>            &lt;Route path=&quot;/component2&quot;&gt;</pre><pre>                &lt;Component2&gt;&lt;/Component2&gt;</pre><pre>            &lt;/Route&gt;</pre><pre>        &lt;/Switch&gt;</pre><pre>    &lt;/Router&gt;</pre><pre>&lt;/ContextVariableProvider&gt;</pre><p><strong><em>Steps for using the value or function we pass through context:</em></strong></p><ol><li>Import ContextAPI function which we made before in ContextAPI.js</li><li>Make variable and assign value as ContextAPI()</li><li>We can access add function now as variable.add(num1, num2)</li></ol><pre>const variable = ContextAPI();</pre><pre>const sum = variable.add(5,6);</pre><pre>console.log(sum);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c74236e6235c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>