sbyeol3/articles

[์ •๋ฆฌ] React Conf 2021

Opened this issue ยท 2 comments

"Great User Experience"

First Block ๐Ÿ‘€

Keynote

  • ์ผ๋ฐ˜ ๊ฐœ๋ฐœ์ž ์™ธ์—๋„ ๋””์ž์ด๋„ˆ๋“ค์—๊ฒŒ React๊ฐ€ ์˜ํ–ฅ์„ ๋ผ์นœ๋‹ค (framer)
  • rooted in design principle, not programming
  • React made components a mainstream part of UI dev => designers and developers speak "the same language"

Suspense

  • Read data over the network as easily as props or state
  • React 16-17์—์„œ์˜ Suspense๋Š” client์—์„œ React.lazy๋ฅผ ์ด์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ๋™์ ์œผ๋กœ ๋กœ๋”ฉํ•˜๋Š” ๊ฒฝ์šฐ์— ์žฅ์ ์ด ์žˆ์—ˆ์Œ
    • SSR์—์„œ๋Š” ๋ถˆ๊ฐ€๋Šฅ
  • React ์ฝ”๋“œ๋Š” top-down์œผ๋กœ ์ฝ๊ธฐ ์ข‹์€๋ฐ ๋น„๋™๊ธฐ ์ฝ”๋“œ๊ฐ€ ๋“ค์–ด๊ฐ€๋Š” ์ˆœ๊ฐ„ ๋ถˆ๊ฐ€๋Šฅํ•ด์ง„๋‹ค.
  • Reading the data + Specifying the loading state
if (isLoading) return <Spinner />;
return (...);

// declarative way !
<Suspense fallback={<Spinner />}>
  <List pageId={pageId} />
</Suspese>

"design centric idea"

  • 16~17 : (c) Code Splitting with React.lazy
  • 18 : (c) Data fetching via compatible libs, like Relay (s) Streaming server rendering
  • Next steps : General support for data fetching, Server components
    • ๋งŽ์€ ์‚ฌ๋žŒ๋“ค์ด Relay๋ฅผ ์‚ฌ์šฉํ•˜์ง€๋Š” ์•Š์Œ, Suspense์™€ Relay๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ  ๋ฐ˜๋ณตํ•˜๋Š” ๊ฒƒ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋งŒ๋“œ๋Š” ์‚ฌ๋žŒ๋„ ํž˜๋“  ์ผ!

Concurrent Redering : "A behind-the-scenes capability in React that powers features like Suspense"

"what์— ์ง‘์ค‘ํ•˜๋ผ, React๋Š” how์— ์ง‘์ค‘ํ•œ๋‹ค . . "

  • concurrent mode๊ฐ€ ์•„๋‹Œ concurrent features!

React without memo

Xuan Huang

React Forget

  • auto memoizing compiler
  • Research project in React Labs
  • familiar React, still React
  • ๋ฉ”๋ชจ์ด์ œ์ด์…˜์€ UX๋ฅผ ํ–ฅ์ƒ์‹œํ‚ค์ง€๋งŒ DX์—๋Š” ์ข‹์ง€ ์•Š๋‹ค.
  • ์ฆ‰, React Forget์€ DX๋ฅผ ์ข‹์ง€ ์•Š๊ฒŒ ๋งŒ๋“œ๋Š” ๋ฉ”๋ชจ์ด์ œ์ด์…˜์„ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ”„๋กœ์ ํŠธ (์•„์ง ๊ณต๊ฐœX)

example code

function TodoList({ visibility, themeColor }) {
  const [todos, setTodos] = useState(initialTodos);
  const handleChange = todo => setTodos(todos => getUpdated(todos, todo));
  const filtered = getFiltered(todos, visibility);

  return (
    <div>
      <ul>
        {filtered.map(todo => (
          <Todo key={todo.id} todo={todo} onChange={handleChange} />
        ))}
      </ul>
      <AddTodo setTodos={setTodos} themeColor={themeColor} />
    </div>
  );
}
function TodoList({ visibility, themeColor }) {
  const [todos, setTodos] = useState(initialTodos)
  let hasVisibilityChanged, hasThemeColorChanged, hasTodosChanged, memoCache

  if (hasVisibilityChanged || hasThemeColorChanged || hasTodosChanged) {
    const handleChange = memoCache[0] || (memoCache[0] = (todo) => setTodos((todos) => getUpdated(todos, todo)))

    let filtered, jsx_todos
    if (hasVisibilityChanged || hasTodosChanged) {
      filtered = memoCache[1] = getFiltered(todos, visibility)
      jsx_todos = memoCache[2] = (
        <ul>
          {filtered.map((todo) => (
            <Todo key={todo.id} todo={todo} onChange={handleChange} />
          ))}
        </ul>
      )
    } else {
      filtered = memoCache[1]
      jsx_todos = memoCache[2]
    }
  }

  const jsx_addTodo = hasThemeColorChanged ? (memoCache[3] = <AddTodo setTodos={setTodos} themeColor={themeColor} />) : memoCache[3]

  return (
    <div>
      {jsx_todos}
      {jsx_addTodo}
    </div>
  )
}

Final Block

React 18 for External Store Libraries

Daishi Kato

  • internal states : props context useState useReducer
  • ์ด ์™ธ์—๋Š” ๋ชจ๋‘ external stores
  • tearing : ์ •๋ณด์˜ ๋ถˆ์ผ์น˜๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ž˜๋ชป๋œ ์Šคํฌ๋ฆฐ์„ ๋ณด์—ฌ์ฃผ๋Š” ๋ฌธ์ œ
  • useSyncExternalStore : React 18์—์„œ ๋„์ž…

useSyncExternalStore

  • subscribe: get callback, return unsubscribe func
  • getSnapshot : return immutable value
  • ์™ธ๋ถ€ ์Šคํ† ์–ด๋ฅผ ๊ตฌ๋…ํ•˜๋Š” ํ˜•ํƒœ

Accessible Japanese Form Components with React

Tafu Nakazaki (SmartHR)

  • ์ผ๋ณธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” administrative docs๋Š” ๋ณต์žกํ•˜๊ณ  ์ดํ•ดํ•˜๊ธฐ๊ฐ€ ์–ด๋ ต๋‹ค (name, age, address, etc ...) ๐Ÿคฏ
  • HR & management๋Š” ๋ณต์žกํ•˜๊ณ  ๋‹ค์–‘ํ•จ
    • ํŠนํžˆ ๋ฌธ์„œ๋ฅผ ์ฝ๋Š” ๊ฒƒ์ด ์–ด๋ ค์šด ๊ฒฝ์šฐ๋„ ์žˆ์Œ ==> web based docs ! (์ ‘๊ทผ์„ฑ์ด ์ฆ๊ฐ€)
    • Web Content Accessibility Guidelines (WCAG)
  • React๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ declarative UI ๊ตฌํ˜„

SSR๊ณผ CSR

์ฐธ๊ณ 

SSR (Server Side Rendering)

  • ์„œ๋ฒ„์—์„œ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ณด์—ฌ์ค„ ํŽ˜์ด์ง€๋ฅผ ๋ชจ๋‘ ๊ตฌ์„ฑํ•˜์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ํŽ˜์ด์ง€๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ๋ฐฉ์‹
  • ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ๋งคํ•‘๋œ ์„œ๋น„์Šค ํŽ˜์ด์ง€๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฐ”๋กœ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ์œผ๋ฉฐ ์ „์ฒด์ ์œผ๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ณด์—ฌ์ฃผ๋Š” ์ปจํ…์ธ ์˜ ๊ตฌ์„ฑ์ด ์™„๋ฃŒ๋˜๋Š” ์‹œ์ ์€ ๋นจ๋ผ์ง€๋ฉฐ, SEO ๋˜ํ•œ ์‰ฝ๊ฒŒ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค.

CSR (Client Side Rendering)

  • ์ดˆ๊ธฐ ์ „์†ก๋˜๋Š” ํŽ˜์ด์ง€์˜ ์†๋“œ๋Š” ๋น ๋ฅด์ง€๋งŒ ์„œ๋น„์Šค์—์„œ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ํด๋ผ์ด์–ธํŠธ์—์„œ ์ถ”๊ฐ€๋กœ ์š”์ฒญํ•˜์—ฌ ์žฌ๊ตฌ์„ฑํ•ด์•ผ ํ•˜๋ฏ€๋กœ ์ „์ฒด์ ์ธ ํŽ˜์ด์ง€ ์™„๋ฃŒ ์‹œ์ ์€ SSR๋ณด๋‹ค ๋Š๋ฆฌ๋‹ค.

React Suspense docs

It's a mechanism for data fetching libraries to communicate to React
that the data a component is reading is not ready yet

  • React 16.6 ๋ฒ„์ „์—์„œ ์ถ”๊ฐ€
  • ๋ฐ์ดํ„ฐ๋ฅผ ๋น„๋กฏํ•œ ๋ฌด์—‡์ด๋“  "๊ธฐ๋‹ค๋ฆด" ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ์ƒˆ๋กœ์šด feature