const AWS = require('aws-sdk')
const spacesEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: 'ACCESS_KEY',
secretAccessKey: 'SECRET_KEY'
Thanks to React hooks you have now happily turned all your classes into functional components.
Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.
There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.
If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.
You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.
If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.
function MyComponent() {
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
| <template> | |
| <ins class="adsbygoogle" | |
| :data-ad-client="adClient" | |
| :data-ad-slot="adSlot" | |
| :data-ad-format="adFormat" | |
| :style="adStyle"></ins> | |
| </template> | |
| <script> | |
| export default { |
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
| #------------------ | |
| # Shell Variables | |
| #------------------ | |
| # Specify VS Code as default editor for the React Native Simulator | |
| export REACT_EDITOR=code-insiders | |
| # Set VS Code Insiders as default code editor | |
| export EDITOR=code-insiders | |
| # Android SDK | |
| export ANDROID_HOME=~/Library/Android/sdk |
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
| /** | |
| * useScroll React custom hook | |
| * Usage: | |
| * const { scrollX, scrollY, scrollDirection } = useScroll(); | |
| */ | |
| import { useState, useEffect } from "react"; | |
| export function useScroll() { | |
| const [lastScrollTop, setLastScrollTop] = useState(0); |
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 axios from "axios" | |
| import { Reducer, Dispatch } from "redux" | |
| import Cookies from "js-cookie" | |
| export type UserState = { | |
| accessToken: string | |
| loggingIn: boolean | |
| error: string | |
| } |
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 (context, trackingId, options) { | |
| const history = context.history; | |
| const doc = document; | |
| const nav = navigator || {}; | |
| const storage = localStorage; | |
| const encode = encodeURIComponent; | |
| const pushState = history.pushState; | |
| const typeException = 'exception'; | |
| const generateId = () => Math.random().toString(36); | |
| const getId = () => { |
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
| Extensions | |
| ========== | |
| ext install wakatime.vscode-wakatime (time tracking) | |
| ext install esbenp.prettier-vscode (prettifier) | |
| ext install ms-vscode.csharp (C#) | |
| ext install mikestead.dotenv (.env files) | |
| ext install msjsdiag.debugger-for-chrome (chrome's debugger) | |
| ext install deerawan.vscode-faker (faker) | |
| ext install ms-vsliveshare.vsliveshare (shared coding sessions) |