Skip to main content

Hooks

State and effects management for your components.

Built-in Hooks

State Management

  • useState - Manage component state.
  • useReducer - Manage complex state logic with a reducer function.
  • useContext - Access context values from Context.

Effects & Lifecycle

  • useEffect - Perform side effects in function components with cleanup support.
  • useExit - Request the UI to be closed.

References

  • useRef - Create a mutable reference that is persisted across executions.

Minecraft specific

  • usePlayer - Access the current player who is viewing the UI.
  • useEvent - Subscribe to global Minecraft events within your UI components.

Next Steps

  • Components - Built-in components that you can use in your JSX
  • API - APIs that are useful for defining components