Skip to content

Instantly share code, notes, and snippets.

View justinbiebur's full-sized avatar
🖕
🔫🖕

Justin Bieber justinbiebur

🖕
🔫🖕
View GitHub Profile
@justinbiebur
justinbiebur / simple-echo-server.js
Created November 13, 2021 07:17
A very simple express server to log id provided as parameter in a get request.
// make sure to add express to package.json
var express = require('express');
var app = express();;
var PORT = 3000;
app.get('/:id', function (req, res) {
console.log(req.params['id']);
res.send();
});
@justinbiebur
justinbiebur / ProtectedRoute.js
Created August 25, 2020 09:53
a part of the medium article on firebase auth and react-router.
import React, { useContext } from 'react';
import {AuthContext}from './firebaseAuthContext';
import {Route,Redirect} from 'react-router-dom';
export default function ProtectedRoute(props){
const authValue=useContext(AuthContext)
if (authValue.userDataPresent){
if(authValue.user==null){
return(<Redirect to={props.redirectTo}></Redirect>)
@justinbiebur
justinbiebur / Route.js
Created August 6, 2020 07:22
Routing without React-Router
const Route = ({ children, href }) => {
var navObj = useContext(NavigationContext);
var copy={...navObj};
switch(copy.pathname){
case href :
return(children);
default: