This file contains 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 { useState, useCallback } from "react"; | |
export default function usePersistedState(key, initialValue) { | |
// State to store our value | |
// Pass initial state function to useState so logic is only executed once | |
const [storedValue, setStoredValue] = useState(() => { | |
try { | |
// Get from local storage by key | |
const item = window.localStorage.getItem(key); | |
// Parse stored json or if none return initialValue |
This file contains 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
const isEmpty = value => value === undefined || value === null || value === ""; | |
const join = rules => (value, data) => | |
rules.map(rule => rule(value, data)).filter(error => !!error)[0]; | |
export function email(value) { | |
if ( | |
!isEmpty(value) && | |
!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) | |
) { | |
return "Invalid e-mail address"; |
This file contains 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 React, { Component } from "react"; | |
import styled from "styled-components"; | |
import SwipeableViews from "react-swipeable-views"; | |
import Nav from "./components/Nav"; | |
import Player from "./components/Player"; | |
import Mensajes from "./components/Mensajes"; | |
const AppContainer = styled.div` | |
height: 100vh; |