This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{/** CHAT HEADER HERE **/} | |
<div className="px-4 pb-4 w-100 d-flex flex-row flex-wrap align-items-start align-content-start position-relative" style={{ height: 'calc(100% - 180px)', overflowY: 'scroll' }}> | |
{this.state.chats.map((chat, index) => { | |
const previous = Math.max(0, index - 1); | |
const previousChat = this.state.chats[previous]; | |
const position = chat.user === this.props.activeUser ? "right" : "left"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FALSY VALUES | |
console.log(!!0); // false | |
console.log(!!-0); // false | |
console.log(!!''); // false | |
console.log(!!false); // false | |
console.log(!!NaN); // false | |
console.log(!!null); // false | |
console.log(!!undefined); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// METHOD 1: Using if statement | |
if (person) { | |
fetchProfile(person); | |
} | |
// METHOD 2: Using short-circuiting | |
person && fetchProfile(person); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// METHOD 1: Using if/else statements | |
let requestAnimFrame = null; | |
if (window.requestAnimationFrame) { | |
requestAnimFrame = window.requestAnimationFrame; | |
} | |
else if (window.webkitRequestAnimationFrame) { | |
requestAnimFrame = window.webkitRequestAnimationFrame; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Function that accepts a boolean as first argument | |
// and returns the boolean otherwise `false` | |
const booleanOrFalse = value => (typeof value == 'boolean') && value; | |
// Function that accepts a boolean as first argument | |
// and returns the boolean otherwise `true` | |
const booleanOrTrue = value => (typeof value != 'boolean') || value; | |
console.log(booleanOrFalse(true)); // true | |
console.log(booleanOrFalse(false)); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" | |
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" | |
crossorigin="anonymous"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" | |
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" | |
crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" | |
integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" | |
crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" | |
integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="theme-color" content="#000000"> | |
<!-- | |
manifest.json provides metadata used when your web app is added to the | |
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | |
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'bootstrap/dist/css/bootstrap.min.css'; | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import registerServiceWorker from './registerServiceWorker'; | |
ReactDOM.render(<App />, document.getElementById('root')); | |
registerServiceWorker(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'bootstrap/dist/css/bootstrap.min.css'; | |
import $ from 'jquery'; | |
import Popper from 'popper.js'; | |
import 'bootstrap/dist/js/bootstrap.bundle.min'; | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import registerServiceWorker from './registerServiceWorker'; |