Skip to content

Feature: Enable React Compiler to remove manual useCallback/useMemo hooks #43

@alamenai

Description

@alamenai

Summary

This project uses React 19.2.1 which includes support for the React Compiler.

Enabling it would allow us to remove manual memoization hooks (useCallback, useMemo) throughout the codebase, as the compiler handles this automatically.

Current State

Components like conversation-bar.tsx have multiple manual useCallback hooks to prevent unnecessary re-renders:

 const getMicStream = React.useCallback(async () => { ... }, [])
 const startConversation = React.useCallback(async () => { ... }, [conversation, getMicStream, agentId, onError])
 const handleEndSession = React.useCallback(() => { ... }, [conversation])
 const toggleMute = React.useCallback(() => { ... }, [])
 const handleStartOrEnd = React.useCallback(() => { ... }, [agentState, handleEndSession, startConversation])
 const handleSendText = React.useCallback(() => { ... }, [conversation, textInput, onSendMessage])
 const handleTextChange = React.useCallback(() => { ... }, [conversation, isConnected])
 const handleKeyDown = React.useCallback(() => { ... }, [handleSendText])

Proposed Change

Enable the React Compiler in next.config.mjs:

    const nextConfig = {
    reactCompiler: true,
    // ...existing config
  }

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions