Capítulo 74 de 988

Chapter 74: useBufferState()

Core Idea

_available from 4. 0.

Key Concepts

  • API
  • delayPlayback()
  • Usage notes
  • Handle unmounting
  • Avoid calling inside useState()
  • Together with delayRender()
  • Compatibility
  • See also

Code Examples

const MyComp: React.FC = () => {
  const buffer = useBufferState();

  React.useEffect(() => {
    const delayHandle = buffer.delayPlayback();

    setTimeout(() => {
      delayHandle.unblock();
    }, 5000);

    return () => {
      delayHandle.unblock();
    };
  }, []);

  return <></>;
};
  • What it demonstrates: Usage pattern for useBufferState() from the official docs.

Key Takeaways

  1. Understand api when working with useBufferState().
  2. Understand delayplayback() when working with useBufferState().
  3. Understand usage notes when working with useBufferState().
  4. Understand handle unmounting when working with useBufferState().
  5. Understand avoid calling inside usestate() when working with useBufferState().

Connects To

  • Cancel Render: related page in the Hooks & Data APIs section.
  • Continue Render: related page in the Hooks & Data APIs section.
  • Data Fetching: related page in the Hooks & Data APIs section.