Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer type conversion not respected #3235

Open
benedikt-bartscher opened this issue May 6, 2024 · 1 comment · May be fixed by #3301
Open

Serializer type conversion not respected #3235

benedikt-bartscher opened this issue May 6, 2024 · 1 comment · May be fixed by #3301
Labels
bug Something isn't working

Comments

@benedikt-bartscher
Copy link
Contributor

Describe the bug

Reflex has builtin serializers for a lot of classes like f.e. datetime and date which serialize to a str.
This should ideally set _var_is_string to affected vars automatically

related pr: #3227

To Reproduce
Steps to reproduce the behavior:

from datetime import date
import reflex as rx

class CC(rx.Component):
    tag = "cc"
    dob: rx.Var[date]

cc = CC.create

today_var = rx.Var.create(date.today())
# this fixes it
# today_var._var_is_string = True

def index() -> rx.Component:
    return cc(dob=today_var)

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

Results in the following Frontend error:

./pages/index.js
Error: 
  x Legacy octal escape is not permitted in strict mode
    ,-[/home/bb/dev/reflex/test-optional/.web/pages/index.js:13:1]
 13 |     <Fragment>
 14 |   <RadixThemesFlex align={`start`} className={`rx-Stack`} direction={`column`} gap={`3`}>
 15 |   <cc/>
 16 |   <cc dob={2024-05-03}/>
    :                 ^^
 17 | </RadixThemesFlex>
 18 |   <NextHead>
 19 |   <title>
    `----

Expected behavior
passing a datetime as prop just works without manual _var_is_string fixups

Specifics (please complete the following information):

  • Python Version: 3.12.3
  • Reflex Version: main branch
  • OS: arch
  • Browser (Optional): ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants