question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for complex types of state values

See original GitHub issue

Hello,

First - thanks for this nice library.

I have one problem with state and Date.

Simple component:

export function DateComponent() {
  const date = useState<Date>(new Date());
  return <div>{date.get().toString()}</div>;
}

Returns

TypeError
_this.child(...).get is not a function

Problem is default value (new Date())

Is this bug or I miss something?

Btw after some investigation -

 date.attach(Downgraded);

works fine.

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
avkonstcommented, Nov 15, 2020

Ok. I will check how to improve this doc. I have also experimented with adding support for Date and other complex JS types. It is possible to make it work for the @hookstate/core. But it is a problem for some plugins, as complex JS types are not JSON serializable - which is a weakness of the JS language itself. Not sure if adding this support is valuable. Until now I managed to work around this language limitation using plain strings…

1reaction
starlabs007commented, Nov 12, 2020

No problem; it’s pretty easy to miss as it’s a small section at the end of a very long page.

@avkonst Perhaps move the limitations section to its own category in the docs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complex Data Types - Oracle Help Center
Complex Data Types. An instance of a complex data type contains multiple values and provides access to its nested values. Currently, Oracle NoSQL...
Read more >
5 Best Practices for Handling State Structure in React
Although it's possible to write working code even with a standard state structure, here are a few steps to help you make better...
Read more >
Programming with State: Values and Entities - Futurice
A view that I've found useful is to divide the objects manipulated by the program into two kinds, values and entities. A value...
Read more >
Introduction to data types and field properties - Microsoft Support
Overview of data types and field properties in Access, and detailed data type reference. including Memo, Date/Time, and Text.
Read more >
Supported Data Types - Trifacta Documentation
Values of these data types are three-digit numeric values, which correspond to recognized HTTP Status Codes. Datetime Data Type, Designer Cloud ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found