├── .gitignore
├── images
├── useRef.jpeg
├── useEffect.png
├── useMemo.jpeg
├── useReducer.png
├── useState.jpeg
├── useContext-app.png
├── useContext-toolbar.png
└── useContext-themedbutton.png
├── use-callback
├── svelte
│ ├── src
│ │ ├── main.js
│ │ ├── expensive.js
│ │ ├── ExpensiveToRenderButton.svelte
│ │ └── App.svelte
│ ├── .gitignore
│ ├── public
│ │ ├── favicon.png
│ │ ├── index.html
│ │ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ │ └── setupTypeScript.js
└── react
│ ├── public
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── index.html
│ ├── src
│ ├── expensive.js
│ ├── setupTests.js
│ ├── ExpensiveToRenderButton.js
│ ├── index.css
│ ├── index.js
│ ├── App.js
│ ├── logo.svg
│ └── serviceWorker.js
│ ├── .gitignore
│ ├── package.json
│ └── README.md
├── use-context
├── svelte
│ ├── src
│ │ ├── main.js
│ │ ├── Toolbar.svelte
│ │ ├── ThemedButton.svelte
│ │ └── App.svelte
│ ├── .gitignore
│ ├── public
│ │ ├── favicon.png
│ │ ├── index.html
│ │ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ │ └── setupTypeScript.js
└── react
│ ├── public
│ ├── robots.txt
│ ├── favicon.ico
│ ├── logo192.png
│ ├── logo512.png
│ ├── manifest.json
│ └── index.html
│ ├── src
│ ├── Toolbar.js
│ ├── setupTests.js
│ ├── ThemedButton.js
│ ├── index.css
│ ├── App.js
│ ├── index.js
│ └── logo.svg
│ ├── .gitignore
│ ├── package.json
│ └── README.md
├── use-effect
├── react
│ ├── public
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── index.html
│ ├── src
│ │ ├── setupTests.js
│ │ ├── index.css
│ │ ├── Timer.js
│ │ ├── index.js
│ │ └── logo.svg
│ ├── .gitignore
│ ├── package.json
│ └── README.md
└── svelte
│ ├── src
│ ├── main.js
│ └── Timer.svelte
│ ├── .gitignore
│ ├── public
│ ├── favicon.png
│ ├── index.html
│ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ └── setupTypeScript.js
├── use-memo
├── react
│ ├── public
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── index.html
│ ├── src
│ │ ├── fib.js
│ │ ├── setupTests.js
│ │ ├── index.css
│ │ ├── Fibonacci.js
│ │ ├── index.js
│ │ └── logo.svg
│ ├── .gitignore
│ ├── package.json
│ └── README.md
└── svelte
│ ├── .gitignore
│ ├── src
│ ├── main.js
│ ├── fib.js
│ └── Fibonacci.svelte
│ ├── public
│ ├── favicon.png
│ ├── index.html
│ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ └── setupTypeScript.js
├── use-ref
├── react
│ ├── public
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── index.html
│ ├── src
│ │ ├── setupTests.js
│ │ ├── TextInputWithFocusButton.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── logo.svg
│ │ └── serviceWorker.js
│ ├── .gitignore
│ ├── package.json
│ └── README.md
└── svelte
│ ├── .gitignore
│ ├── public
│ ├── favicon.png
│ ├── index.html
│ └── global.css
│ ├── src
│ ├── main.js
│ └── TextInputWithFocusButton.svelte
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ └── setupTypeScript.js
├── use-state
├── react
│ ├── public
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── index.html
│ ├── src
│ │ ├── setupTests.js
│ │ ├── index.css
│ │ ├── Counter.js
│ │ ├── index.js
│ │ └── logo.svg
│ ├── .gitignore
│ ├── package.json
│ └── README.md
└── svelte
│ ├── src
│ ├── main.js
│ └── Counter.svelte
│ ├── .gitignore
│ ├── public
│ ├── favicon.png
│ ├── index.html
│ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ └── setupTypeScript.js
├── use-reducer
├── react
│ ├── public
│ │ ├── robots.txt
│ │ ├── favicon.ico
│ │ ├── logo192.png
│ │ ├── logo512.png
│ │ ├── manifest.json
│ │ └── index.html
│ ├── src
│ │ ├── setupTests.js
│ │ ├── index.css
│ │ ├── index.js
│ │ ├── Counter.js
│ │ └── logo.svg
│ ├── .gitignore
│ ├── package.json
│ └── README.md
└── svelte
│ ├── .gitignore
│ ├── src
│ ├── main.js
│ └── Counter.svelte
│ ├── public
│ ├── favicon.png
│ ├── index.html
│ └── global.css
│ ├── package.json
│ ├── .eslintrc.js
│ ├── rollup.config.js
│ ├── README.md
│ └── scripts
│ └── setupTypeScript.js
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | public/build
2 |
--------------------------------------------------------------------------------
/images/useRef.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useRef.jpeg
--------------------------------------------------------------------------------
/images/useEffect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useEffect.png
--------------------------------------------------------------------------------
/images/useMemo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useMemo.jpeg
--------------------------------------------------------------------------------
/images/useReducer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useReducer.png
--------------------------------------------------------------------------------
/images/useState.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useState.jpeg
--------------------------------------------------------------------------------
/use-callback/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import App from './App.svelte'
2 |
3 | new App({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-context/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import App from './App.svelte'
2 |
3 | new App({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-effect/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-effect/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import Timer from './Timer.svelte'
2 |
3 | new Timer({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-memo/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-ref/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-state/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/images/useContext-app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useContext-app.png
--------------------------------------------------------------------------------
/use-callback/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-context/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-memo/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-reducer/react/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/use-ref/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-state/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import Counter from './Counter.svelte'
2 |
3 | new Counter({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-callback/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-context/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-effect/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-memo/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import Fibonacci from './Fibonacci.svelte'
2 |
3 | new Fibonacci({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-reducer/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/use-reducer/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import Counter from './Counter.svelte'
2 |
3 | new Counter({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-state/svelte/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 | /yarn-error.log
4 | /yarn.lock
5 |
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/images/useContext-toolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useContext-toolbar.png
--------------------------------------------------------------------------------
/use-memo/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-memo/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-memo/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-memo/react/public/logo192.png
--------------------------------------------------------------------------------
/use-memo/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-memo/react/public/logo512.png
--------------------------------------------------------------------------------
/use-ref/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-ref/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-ref/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-ref/react/public/logo192.png
--------------------------------------------------------------------------------
/use-ref/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-ref/react/public/logo512.png
--------------------------------------------------------------------------------
/use-ref/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-ref/svelte/public/favicon.png
--------------------------------------------------------------------------------
/images/useContext-themedbutton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/images/useContext-themedbutton.png
--------------------------------------------------------------------------------
/use-callback/react/src/expensive.js:
--------------------------------------------------------------------------------
1 | export default function() {
2 | let i = 0
3 | while (i<10000000) {
4 | i+=1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/use-callback/svelte/src/expensive.js:
--------------------------------------------------------------------------------
1 | export default function() {
2 | let i = 0
3 | while (i<10000000) {
4 | i+=1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/use-context/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-context/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-context/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-context/react/public/logo192.png
--------------------------------------------------------------------------------
/use-context/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-context/react/public/logo512.png
--------------------------------------------------------------------------------
/use-effect/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-effect/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-effect/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-effect/react/public/logo192.png
--------------------------------------------------------------------------------
/use-effect/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-effect/react/public/logo512.png
--------------------------------------------------------------------------------
/use-effect/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-effect/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-memo/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-memo/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-reducer/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-reducer/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-reducer/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-reducer/react/public/logo192.png
--------------------------------------------------------------------------------
/use-reducer/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-reducer/react/public/logo512.png
--------------------------------------------------------------------------------
/use-state/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-state/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-state/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-state/react/public/logo192.png
--------------------------------------------------------------------------------
/use-state/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-state/react/public/logo512.png
--------------------------------------------------------------------------------
/use-state/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-state/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-callback/react/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-callback/react/public/favicon.ico
--------------------------------------------------------------------------------
/use-callback/react/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-callback/react/public/logo192.png
--------------------------------------------------------------------------------
/use-callback/react/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-callback/react/public/logo512.png
--------------------------------------------------------------------------------
/use-callback/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-callback/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-context/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-context/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-reducer/svelte/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshnuss/react-hooks-in-svelte/HEAD/use-reducer/svelte/public/favicon.png
--------------------------------------------------------------------------------
/use-context/svelte/src/Toolbar.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/use-memo/react/src/fib.js:
--------------------------------------------------------------------------------
1 | export default function fibonacci(num) {
2 | if (num <= 1) return 1
3 |
4 | return fibonacci(num - 1) + fibonacci(num - 2)
5 | }
6 |
--------------------------------------------------------------------------------
/use-memo/svelte/src/fib.js:
--------------------------------------------------------------------------------
1 | export default function fibonacci(num) {
2 | if (num <= 1) return 1
3 |
4 | return fibonacci(num - 1) + fibonacci(num - 2)
5 | }
6 |
--------------------------------------------------------------------------------
/use-ref/svelte/src/main.js:
--------------------------------------------------------------------------------
1 | import TextInputWithFocusButton from './TextInputWithFocusButton.svelte'
2 |
3 | new TextInputWithFocusButton({target: document.body})
4 |
--------------------------------------------------------------------------------
/use-context/react/src/Toolbar.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ThemedButton from './ThemedButton'
3 |
4 | export default function Toolbar() {
5 | return
6 | }
7 |
--------------------------------------------------------------------------------
/use-callback/svelte/src/ExpensiveToRenderButton.svelte:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/use-state/svelte/src/Counter.svelte:
--------------------------------------------------------------------------------
1 |
4 |
5 | Count: {count}
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/use-memo/svelte/src/Fibonacci.svelte:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
fib({value}) = {result}
11 |
--------------------------------------------------------------------------------
/use-ref/svelte/src/TextInputWithFocusButton.svelte:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/use-memo/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-ref/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-state/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-callback/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-context/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-context/svelte/src/ThemedButton.svelte:
--------------------------------------------------------------------------------
1 |
6 |
7 |
10 |
--------------------------------------------------------------------------------
/use-effect/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-reducer/react/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import '@testing-library/jest-dom/extend-expect';
6 |
--------------------------------------------------------------------------------
/use-effect/svelte/src/Timer.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 | Timer: {count}
16 |
--------------------------------------------------------------------------------
/use-callback/react/src/ExpensiveToRenderButton.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import expensiveComputation from './expensive'
3 |
4 | function ExpensiveToRenderButton({onClick}) {
5 | expensiveComputation()
6 |
7 | return
8 | }
9 |
10 | export default React.memo(ExpensiveToRenderButton)
11 |
--------------------------------------------------------------------------------
/use-callback/svelte/src/App.svelte:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/use-context/react/src/ThemedButton.js:
--------------------------------------------------------------------------------
1 | import React, { useContext } from 'react'
2 | import { ThemeContext } from './App'
3 |
4 | export default function ThemedButton() {
5 | const theme = useContext(ThemeContext)
6 |
7 | return (
8 |
11 | )
12 | }
13 |
--------------------------------------------------------------------------------
/use-ref/react/src/TextInputWithFocusButton.js:
--------------------------------------------------------------------------------
1 | import React, { useRef } from 'react'
2 |
3 | export default function TextInputWithFocusButton() {
4 | const inputEl = useRef(null)
5 | const handleClick = () => {
6 | inputEl.current.focus()
7 | }
8 |
9 | return (
10 | <>
11 |
12 |
13 | >
14 | )
15 | }
16 |
--------------------------------------------------------------------------------
/use-effect/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-memo/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-ref/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-state/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-callback/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-context/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-context/svelte/src/App.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/use-reducer/react/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | npm-debug.log*
22 | yarn-debug.log*
23 | yarn-error.log*
24 |
--------------------------------------------------------------------------------
/use-context/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-effect/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-memo/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-reducer/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-ref/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-state/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-callback/react/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5 | sans-serif;
6 | -webkit-font-smoothing: antialiased;
7 | -moz-osx-font-smoothing: grayscale;
8 | }
9 |
10 | code {
11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 | monospace;
13 | }
14 |
--------------------------------------------------------------------------------
/use-effect/react/src/Timer.js:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react'
2 |
3 | export default function Timer() {
4 | const [count, setCount] = useState(0)
5 |
6 | useEffect(() => {
7 | const interval = setInterval(() => {
8 | setCount(count => count + 1)
9 | }, 1000)
10 |
11 | return () => clearInterval(interval)
12 | }, [])
13 |
14 | return (
15 | <>
16 | Timer: {count}
17 | >
18 | )
19 | }
20 |
--------------------------------------------------------------------------------
/use-state/react/src/Counter.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react'
2 |
3 | export default function Counter() {
4 | const [count, setCount] = useState(0)
5 |
6 | return (
7 | <>
8 | Count: {count}
9 |
10 |
11 |
12 | >
13 | )
14 | }
15 |
--------------------------------------------------------------------------------
/use-reducer/svelte/src/Counter.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 | Count: {$count}
16 |
17 |
18 |
--------------------------------------------------------------------------------
/use-memo/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-ref/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-state/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-callback/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-context/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-effect/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-reducer/svelte/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/use-context/react/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { createContext } from 'react'
2 | import Toolbar from './Toolbar'
3 |
4 | const themes = {
5 | light: {
6 | foreground: "#000000",
7 | background: "#eeeeee"
8 | },
9 | dark: {
10 | foreground: "#ffffff",
11 | background: "#222222"
12 | }
13 | };
14 |
15 | export const ThemeContext = createContext(themes.light)
16 |
17 | export default function App() {
18 | return (
19 |
20 |
21 |
22 | )
23 | }
24 |
--------------------------------------------------------------------------------
/use-memo/react/src/Fibonacci.js:
--------------------------------------------------------------------------------
1 | import React, { useMemo, useState } from 'react'
2 | import fibonacci from './fib'
3 |
4 | export default function Fibonacci() {
5 | const [value, setValue] = useState(0)
6 | const result = useMemo(() => {
7 | return fibonacci(value)
8 | }, [value])
9 |
10 | const handleChange = (e) => {
11 | setValue(e.target.value)
12 | }
13 |
14 | return (
15 | <>
16 |
17 | fib({value}) = {result}
18 | >
19 | )
20 | }
21 |
--------------------------------------------------------------------------------
/use-callback/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-context/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-effect/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import Timer from './Timer';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-reducer/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import Counter from './Counter';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-state/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import Counter from './Counter';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-memo/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import Fibonacci from './Fibonacci';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-memo/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-ref/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-callback/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-context/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-effect/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-reducer/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-state/react/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/use-callback/react/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useState } from 'react'
2 | import ExpensiveToRenderButton from './ExpensiveToRenderButton'
3 |
4 | export default function App() {
5 | const [name, setName] = useState("world")
6 | const [age, setAge] = useState(4534000000)
7 |
8 | const handleClick = useCallback(() => {
9 | alert(`Hello ${name}!`)
10 | }, [name])
11 |
12 | return (
13 | <>
14 | setName(e.target.value)} value={name}/>
15 | setAge(e.target.value)} value={age}/>
16 |
17 | >
18 | )
19 | }
20 |
--------------------------------------------------------------------------------
/use-ref/react/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import TextInputWithFocusButton from './TextInputWithFocusButton';
5 | import * as serviceWorker from './serviceWorker';
6 |
7 | ReactDOM.render(
8 |
9 |
10 | ,
11 | document.getElementById('root')
12 | );
13 |
14 | // If you want your app to work offline and load faster, you can change
15 | // unregister() to register() below. Note this comes with some pitfalls.
16 | // Learn more about service workers: https://bit.ly/CRA-PWA
17 | serviceWorker.unregister();
18 |
--------------------------------------------------------------------------------
/use-ref/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-callback/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-context/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-effect/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-memo/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-reducer/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-state/svelte/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "build": "rollup -c",
6 | "dev": "rollup -c -w",
7 | "start": "sirv public",
8 | "lint": "eslint . --ext .js,.svelte"
9 | },
10 | "devDependencies": {
11 | "@rollup/plugin-commonjs": "^14.0.0",
12 | "@rollup/plugin-node-resolve": "^8.0.0",
13 | "eslint": "^7.11.0",
14 | "eslint-plugin-svelte3": "^2.7.3",
15 | "rollup": "^2.3.4",
16 | "rollup-plugin-livereload": "^2.0.0",
17 | "rollup-plugin-svelte": "^6.0.0",
18 | "rollup-plugin-terser": "^7.0.0",
19 | "svelte": "^3.0.0"
20 | },
21 | "dependencies": {
22 | "sirv-cli": "^1.0.0"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/use-reducer/react/src/Counter.js:
--------------------------------------------------------------------------------
1 | import React, { useReducer } from 'react'
2 |
3 | const initialState = {count: 0}
4 |
5 | function reducer(state, action) {
6 | switch (action.type) {
7 | case 'increment':
8 | return {count: state.count + 1}
9 | case 'decrement':
10 | return {count: state.count - 1}
11 | default:
12 | throw new Error()
13 | }
14 | }
15 |
16 | export default function Counter() {
17 | const [state, dispatch] = useReducer(reducer, initialState)
18 | return (
19 | <>
20 | Count: {state.count}
21 |
22 |
23 | >
24 | )
25 | }
26 |
--------------------------------------------------------------------------------
/use-effect/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-memo/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-ref/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-state/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-callback/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-context/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-reducer/svelte/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | es6: true,
5 | node: true
6 | },
7 | plugins: ['svelte3'],
8 | ignorePatterns: ['node_modules/', 'public/build'],
9 | extends: 'eslint:recommended',
10 | globals: {
11 | Atomics: 'readonly',
12 | SharedArrayBuffer: 'readonly'
13 | },
14 | parserOptions: {
15 | ecmaVersion: 2019,
16 | sourceType: 'module'
17 | },
18 | overrides: [
19 | {
20 | files: ['**/*.svelte'],
21 | processor: 'svelte3/svelte3'
22 | }
23 | ],
24 | rules: {
25 | indent: [
26 | 'error',
27 | 2
28 | ],
29 | 'linebreak-style': [
30 | 'error',
31 | 'unix'
32 | ],
33 | quotes: [
34 | 'error',
35 | 'single'
36 | ],
37 | semi: [
38 | 'error',
39 | 'never'
40 | ]
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/use-memo/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-ref/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-callback/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-context/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-effect/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-reducer/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-state/react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^4.2.4",
7 | "@testing-library/react": "^9.3.2",
8 | "@testing-library/user-event": "^7.1.2",
9 | "react": "^16.13.1",
10 | "react-dom": "^16.13.1",
11 | "react-scripts": "3.4.3"
12 | },
13 | "scripts": {
14 | "start": "react-scripts start",
15 | "build": "react-scripts build",
16 | "test": "react-scripts test",
17 | "eject": "react-scripts eject"
18 | },
19 | "eslintConfig": {
20 | "extends": "react-app"
21 | },
22 | "browserslist": {
23 | "production": [
24 | ">0.2%",
25 | "not dead",
26 | "not op_mini all"
27 | ],
28 | "development": [
29 | "last 1 chrome version",
30 | "last 1 firefox version",
31 | "last 1 safari version"
32 | ]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/use-ref/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-callback/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-context/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-effect/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-memo/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-reducer/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-state/svelte/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/use-ref/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-callback/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-context/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-effect/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-memo/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-reducer/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-state/react/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | React App
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/use-memo/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-ref/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-state/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-callback/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-context/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-effect/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-reducer/svelte/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte'
2 | import resolve from '@rollup/plugin-node-resolve'
3 | import commonjs from '@rollup/plugin-commonjs'
4 | import livereload from 'rollup-plugin-livereload'
5 | import { terser } from 'rollup-plugin-terser'
6 |
7 | const production = !process.env.ROLLUP_WATCH
8 |
9 | function serve() {
10 | let server
11 |
12 | function toExit() {
13 | if (server) server.kill(0)
14 | }
15 |
16 | return {
17 | writeBundle() {
18 | if (server) return
19 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20 | stdio: ['ignore', 'inherit', 'inherit'],
21 | shell: true
22 | })
23 |
24 | process.on('SIGTERM', toExit)
25 | process.on('exit', toExit)
26 | }
27 | }
28 | }
29 |
30 | export default {
31 | input: 'src/main.js',
32 | output: {
33 | sourcemap: true,
34 | format: 'iife',
35 | name: 'app',
36 | file: 'public/build/bundle.js'
37 | },
38 | plugins: [
39 | svelte({
40 | // enable run-time checks when not in production
41 | dev: !production,
42 | // we'll extract any component CSS out into
43 | // a separate file - better for performance
44 | css: css => {
45 | css.write('bundle.css')
46 | }
47 | }),
48 |
49 | // If you have external dependencies installed from
50 | // npm, you'll most likely need these plugins. In
51 | // some cases you'll need additional configuration -
52 | // consult the documentation for details:
53 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
54 | resolve({
55 | browser: true,
56 | dedupe: ['svelte']
57 | }),
58 | commonjs(),
59 |
60 | // In dev mode, call `npm run start` once
61 | // the bundle has been generated
62 | !production && serve(),
63 |
64 | // Watch the `public` directory and refresh the
65 | // browser on changes when not in production
66 | !production && livereload('public'),
67 |
68 | // If we're building for production (npm run build
69 | // instead of npm run dev), minify
70 | production && terser()
71 | ],
72 | watch: {
73 | clearScreen: false
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/use-effect/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-memo/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-ref/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-state/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-callback/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-context/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-reducer/react/src/logo.svg:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/use-context/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-effect/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-memo/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-reducer/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-ref/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-state/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-callback/react/README.md:
--------------------------------------------------------------------------------
1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2 |
3 | ## Available Scripts
4 |
5 | In the project directory, you can run:
6 |
7 | ### `yarn start`
8 |
9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11 |
12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console.
14 |
15 | ### `yarn test`
16 |
17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19 |
20 | ### `yarn build`
21 |
22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance.
24 |
25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed!
27 |
28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29 |
30 | ### `yarn eject`
31 |
32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33 |
34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35 |
36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37 |
38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39 |
40 | ## Learn More
41 |
42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43 |
44 | To learn React, check out the [React documentation](https://reactjs.org/).
45 |
46 | ### Code Splitting
47 |
48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49 |
50 | ### Analyzing the Bundle Size
51 |
52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53 |
54 | ### Making a Progressive Web App
55 |
56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57 |
58 | ### Advanced Configuration
59 |
60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61 |
62 | ### Deployment
63 |
64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65 |
66 | ### `yarn build` fails to minify
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
69 |
--------------------------------------------------------------------------------
/use-context/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-effect/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-memo/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-reducer/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-ref/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-state/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/use-callback/svelte/README.md:
--------------------------------------------------------------------------------
1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
2 |
3 | ---
4 |
5 | # svelte app
6 |
7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
8 |
9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
10 |
11 | ```bash
12 | npx degit sveltejs/template svelte-app
13 | cd svelte-app
14 | ```
15 |
16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.*
17 |
18 |
19 | ## Get started
20 |
21 | Install the dependencies...
22 |
23 | ```bash
24 | cd svelte-app
25 | npm install
26 | ```
27 |
28 | ...then start [Rollup](https://rollupjs.org):
29 |
30 | ```bash
31 | npm run dev
32 | ```
33 |
34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
35 |
36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
37 |
38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
39 |
40 | ## Building and running in production mode
41 |
42 | To create an optimised version of the app:
43 |
44 | ```bash
45 | npm run build
46 | ```
47 |
48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
49 |
50 |
51 | ## Single-page app mode
52 |
53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
54 |
55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
56 |
57 | ```js
58 | "start": "sirv public --single"
59 | ```
60 |
61 | ## Using TypeScript
62 |
63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
64 |
65 | ```bash
66 | node scripts/setupTypeScript.js
67 | ```
68 |
69 | Or remove the script via:
70 |
71 | ```bash
72 | rm scripts/setupTypeScript.js
73 | ```
74 |
75 | ## Deploying to the web
76 |
77 | ### With [Vercel](https://vercel.com)
78 |
79 | Install `vercel` if you haven't already:
80 |
81 | ```bash
82 | npm install -g vercel
83 | ```
84 |
85 | Then, from within your project folder:
86 |
87 | ```bash
88 | cd public
89 | vercel deploy --name my-project
90 | ```
91 |
92 | ### With [surge](https://surge.sh/)
93 |
94 | Install `surge` if you haven't already:
95 |
96 | ```bash
97 | npm install -g surge
98 | ```
99 |
100 | Then, from within your project folder:
101 |
102 | ```bash
103 | npm run build
104 | surge public my-project.surge.sh
105 | ```
106 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Hooks in Svelte
2 |
3 | [React Hook](https://reactjs.org/docs/hooks-intro.html) examples ported to [Svelte](https://svelte.dev).
4 |
5 | **New 📣**: [React ⇆ Svelte Cheatsheet](https://dev.to/joshnuss/react-to-svelte-cheatsheet-1a2a)
6 |
7 | # useState
8 |
9 | In Svelte, `const [varName, set] = useState(initialValue)` becomes `let varName = initialValue`. The setter function is replaced with JavaScript's assignment operator `=`.
10 |
11 | [React example](/use-state/react/src/Counter.js)
12 | [Svelte example](/use-state/svelte/src/Counter.svelte)
13 |
14 | 
15 |
16 | # useEffect
17 |
18 | In React, there are 3 ways to `useEffect()`.
19 |
20 | 1. With `null` dependencies: `useEffect(fn)`. This runs on every render.
21 | 2. With an empty array as dependencies: `useEffect(fn, [])`. This runs during mount, and cleanup function runs on unmount.
22 | 3. With a list of dependency vars: `useEffect(fn, [a, b, c])`. This reavaulates whenever a dependency changes. The cleanup runs whenever dependencies change and during unmount.
23 |
24 | This is an example of #2, where the callback runs when component is mounted and cleanup runs when unmounted.
25 |
26 | [React example](/use-effect/react/src/Timer.js)
27 | [Svelte example](/use-effect/svelte/src/Timer.svelte)
28 |
29 | 
30 |
31 | # useMemo
32 |
33 | [React example](/use-memo/react/src/Fibonacci.js)
34 | [Svelte example](/use-memo/svelte/src/Fibonacci.svelte)
35 |
36 | In Svelte, all reactive statements are memoized. Instead of `const var = useMemo(() => expression, dependencies)`, you can use `$: var = expression`. Notice that with Svelte, you don't need to declare the dependencies. The compiler infers them for you.
37 |
38 | 
39 |
40 | # useRef
41 |
42 | [React example](/use-ref/react/src/TextInputWithFocusButton.js)
43 | [Svelte example](/use-ref/svelte/src/TextInputWithFocusButton.svelte)
44 |
45 | In Svelte, `useRef()` is `bind:this`.
46 |
47 | 
48 |
49 | # useReducer
50 |
51 | [React example](/use-reducer/react/src/Counter.js)
52 | [Svelte example](/use-reducer/svelte/src/Counter.svelte)
53 |
54 | In Svelte, `useReducer()` can be replaced with a `writable()` store. Instead of dispatching using a `switch` statement, functions can be defined on the store directly.
55 |
56 | 
57 |
58 | # useCallback
59 |
60 | In React, `useCallback` is used to memoize functions. This is needed because event handlers are re-defined on every render.
61 |
62 | Take this example:
63 |
64 | ```js
65 | // This function (component) is executed on every render
66 | function Component() {
67 | // this event handler is redefined on every render
68 | const handleClick = () => alert("hello")
69 |
70 | // because `handleClick` is redefined on every render, `ChildComponent` will be re-rendered too. Because its `onClick` prop is considered changed.
71 | return
72 | }
73 | ```
74 |
75 | So we need to wrap `handleClick` in a `useCallback`, to give a hint to the rendering system that the handler wasn't changed.
76 |
77 | In Svelte this isn't needed, because event handlers are declared inside `
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('
8 |
9 | As well as validating the code for CI.
10 | */
11 |
12 | /** To work on this script:
13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
14 | */
15 |
16 | const fs = require('fs')
17 | const path = require('path')
18 | const { argv } = require('process')
19 |
20 | const projectRoot = argv[2] || path.join(__dirname, '..')
21 |
22 | // Add deps to pkg.json
23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf8'))
24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
25 | 'svelte-check': '^1.0.0',
26 | 'svelte-preprocess': '^4.0.0',
27 | '@rollup/plugin-typescript': '^6.0.0',
28 | 'typescript': '^3.9.3',
29 | 'tslib': '^2.0.0',
30 | '@tsconfig/svelte': '^1.0.0'
31 | })
32 |
33 | // Add script for checking
34 | packageJSON.scripts = Object.assign(packageJSON.scripts, {
35 | 'validate': 'svelte-check'
36 | })
37 |
38 | // Write the package JSON
39 | fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify(packageJSON, null, ' '))
40 |
41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
42 | const beforeMainJSPath = path.join(projectRoot, 'src', 'main.js')
43 | const afterMainTSPath = path.join(projectRoot, 'src', 'main.ts')
44 | fs.renameSync(beforeMainJSPath, afterMainTSPath)
45 |
46 | // Switch the app.svelte file to use TS
47 | const appSveltePath = path.join(projectRoot, 'src', 'App.svelte')
48 | let appFile = fs.readFileSync(appSveltePath, 'utf8')
49 | appFile = appFile.replace('