- Our Company
- Quick history
- React Router
- Reach UI
- 20 Minute React™
- "Declarative", "Composable", "Functional"
- show off most APIs all at once, build up a little sort/filter searchable list
- Review "React Application Anatomy"
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
// @flow | |
import * as React from 'react'; | |
// inside functional components, you can drop this hook | |
// and be notified when the modified component re-renders. | |
// this component will also tell you _why_ it was re-rendered | |
export default function useTraceUpdate(props: any) { | |
const prev = React.useRef(props); | |
React.useEffect(() => { |
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 React, { useEffect, useRef } from 'react'; | |
function MatrixBackground({ timeout = 50 }) { | |
const canvas = useRef(); | |
useEffect(() => { | |
const context = canvas.current.getContext('2d'); | |
const width = document.body.offsetWidth; | |
const height = document.body.offsetHeight; |
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 { useEffect, useRef } from 'react'; | |
function useDelayedEffect(effect, changingStateVars = [], delay = 1000) { | |
const mutable = useRef(); | |
const delayedEffect = () => { | |
mutable.current = setTimeout(effect, delay); | |
return () => { | |
clearTimeout(mutable.current); |
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"> | |
<title>Scoped CSS Variables and JS</title> | |
</head> | |
<body> | |
<h2>Update CSS Variables with <span class='hl'>JS</span></h2> | |
<div class="controls"> |
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 React, { useEffect } from 'react'; | |
const changeCssVariable = (name: string, value: string) => { | |
document.documentElement.style.setProperty(name, value); | |
}; | |
const changeTheme = (type: 'light' | 'black' | 'dark') => { | |
switch (type) { | |
case 'light': | |
changeCssVariable('--color1', 'white'); |
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
.loader { | |
position: relative; | |
width: 200px; | |
height: 200px; | |
background-color: rgb(31, 31, 31); | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
transition: .5s; | |
color: white; |
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 React, { useState } from 'react'; | |
// https://gist.githubusercontent.com/mfrancois3k/8c65cb0eca62d65cf213cb072e5016f1/raw/7e35a50ea8897025526cbed48fdb3acf70684729/SignupComponent.js | |
const useWindow = (): {isMobile:boolean, isTablet:boolean, isDesktop:boolean} => { | |
const [isMobile, setIsMobile] = useState(false); | |
const [isTablet, setIsTablet] = useState(false); | |
const [isDesktop, setIsDesktop] = useState(true); |
Simply and easily with Styled components
npm install styled-components
Thats all you need to do. Really! That’s why I love it! No Babel, no Webpack, no CSS pre or post processing. Only JavaScript and nothing else.
“You mean CSS in JS? Man, that’s weird. I would never do that!” Don’t panic. Just let me show you few examples why this is a great idea. But let’s write some Styled component first:
import styled from 'styled-components;