rx.Script causes UNSAFE_componentWillMount warning

Open
#5,780 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
frontend

Research direction

Start with the minimal Reflex app in the issue and reproduce the browser-console warning from rx.script under strict mode. Trace the rx.script rendering path to identify the source of the warning, then verify that the same reproduction runs without the UNSAFE_componentWillMount warning.

Written by the indexing model from the issue text.

Description

Describe the bug
A clear and concise description of what the bug is.

When using rx.script I get the Warning: "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code." Is this a mistake on my part or unintended behaviour?

To Reproduce
Steps to reproduce the behavior:

  1. Make a reflex app
  2. Open it on the browser
  3. Check the browser console
  • Code/Link to Repo:
import reflex as rx


def index() -> rx.Component:
    return rx.vstack(
        rx.text("Hello, Reflex!"), rx.script("console.log('inline javascript')")
    )


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

Expected behavior
A clear and concise description of what you expected to happen.

No Warning

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

Image

Specifics (please complete the following information):

  • Python Version: 3.13
  • Reflex Version: 0.8.8 / 0.8.10
  • OS: Linux
  • Browser (Optional): Chrome

Additional context
Add any other context about the problem here.

Dominant language
Python
Stars
28.9k
Forks
1.8k
Avg merge
2d 2h
Merged PRs (30d)
170

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reflex-dev/reflex

All issues in reflex-dev/reflex

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.