catalog icon indicating copy to clipboard operation
catalog copied to clipboard

state can only be strings?

Open mattfelten opened this issue 6 years ago • 2 comments

```react|plain,light,span-3
state: {
	date: new Date(),
}
---
<div>{state.date}</div>

^^ shows up as "new Date()", like it's turned into a string instead of generating a date.

Saving new Date() to an external variable and passing that variable through to state turns the name of the variable to a string also.

Any ideas how to have an example using todays date in a real date format?

mattfelten avatar Jan 24 '20 23:01 mattfelten

Have you tried using a query string at all?

state: {
	date: `${new Date()}`,
}

Jordan-Morrison avatar Mar 02 '20 21:03 Jordan-Morrison

I haven't. Does that work?

mattfelten avatar Mar 02 '20 21:03 mattfelten