Closed sc0ttj closed 3 years ago
also see this for ideas: https://github.com/fabiospampinato/store/blob/master/resources/demo.png
Not needed, very low priority.. Closing.
Very small, easy to use Observable library: https://github.com/jbreckmckye/trkl
fromState
Aside from adding more React-like modules (useState, useEffect, etc) I'd also like something even simpler than
useState
- afromState
method that simply works like so:At a minimum,
fromState()
would basically do this:..as far as I understand it, the above pattern should work because:
props
received by the component will be known tofromState
without having to pass it inthis
keyword in thefromState
function will refer to the component in which it's called, as long as:fromState
is an arrow function...I need to test that theory...
Modified use-st8
Another option may be to extend use-st8 so that the functions it returns have a custom
.toString()
method, which return the state property value that the func is responsible for.That way, you could update the state as in use-st8, but also use them as ordinary variables in your HTML templates... like so:
using Observables
...even better... also use observables to create a much nicer, cleaner syntax: