ts-react-struct
ts-react-struct
is a TypeScript package for using React
and immutable.js
with type-safe cursors and a central event system.
The emphasis here is on type-safety.
You'll usually want to combine this with ts-immutable-struct.
Getting started
Install the package:
npm install --save ts-immutable-struct ts-react-struct
Example usage:
render data.observe
Now, the state is always in sync with the DOM:
data.get'value'.deref// => "ahoy" data.get'value'.val'hola'// => Input gets rerendered as <input value="hola" /> // <= user types "hey" into input fielddata.get'value'.deref // => "hey"