Skip to content

Minimal ComponentState example causes frontend exception (TypeError: d is not a function) in production mode on Reflex 0.9.4 #6616

Description

@TianyiLi10

Describe the bug
Using a ComponentState component causes a frontend exception when running a Reflex application in production mode (reflex run --env prod). It only happens for reflex 0.9.x and run with: reflex run --env prod.

The application works as expected without any exceptions during development (reflex run --env dev), but when running in production mode (reflex run --env prod), the frontend throws the following error:

[Reflex Frontend Exception] TypeError: d is not a function TypeError: d is not a function at Socket. (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:15:10561) at Emitter.emit (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:6018) at Socket.emitEvent (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:37733) at Socket.onevent (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:37540) at Socket.onpacket (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:37184) at Emitter.emit (http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:6018) at http://localhost:3001/assets/createLucideIcon-Bd4MDh-a.js:1:43264

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Reflex application with the code pasted above
  2. Run the application in production mode: reflex run --env prod
  3. Observe the frontend exception in terminal
  • Code/Link to Repo:
import reflex as rx
from rxconfig import config


class TestComponentState(rx.ComponentState):
    name: str

    @classmethod
    def get_component(
        cls,
        name: str,
    ):
        return rx.flex(rx.text(name))


def index() -> rx.Component:
    return rx.container(
        rx.color_mode.button(position="top-right"),
        rx.vstack(
            rx.heading("Welcome to Reflex!", size="9"),
            rx.text(
                "Get started by editing ",
                rx.code(f"{config.app_name}/{config.app_name}.py"),
                size="5",
            ),
            TestComponentState.create(name="Test Component State"),
            spacing="5",
            justify="center",
            min_height="85vh",
        ),
    )


app = rx.App()
app.add_page(index)

Expected behavior
production mode without any frontend exceptions.

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 3.11
  • Reflex Version: 0.9.4
  • OS: Linux
  • Browser (Optional): Chrome

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions