| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
„Everything should be made as simple as possible, but no simpler.” - Albert Einstein
SpringType combines the best parts of the React API with the simplicity of jQuery:
import { tsx, render, Ref } from "springtype";
import { $ } from "st-query";
interface HelloMessageProps {
text: string;
}
// a functional component, just like in React
// but it only renders one time
const HelloMessage = ({ text }: HelloMessageProps) => {
// reference is stored when the element is created
const messageRef: Ref = {};
// because there is no magic re-rendering,
// we can safely use setInterval() and can also
// safely wave goodbye to fancy hooks like useCallback() or useEffect()!
setInterval(() => {
// in case we want to change the rendering,
// we just do this programmatically, where it's needed
$(messageRef.current).html(<p>SpringType </p>);
}, 1000 /* 1 sec */);
return (
<div ref={messageRef}>
Hello, {text}!
</div>
)
}
// SpringType renders to document.body by default
// but you can just provide a second argument to change this
render(<HelloMessage text="World" />);For a more complex demo, see: TODO list demo
Less is more! Complexity is the devil! SpringType does render the TSX structure only one-time.
SpringType does NOT update the DOM. This takes away tons of complexity and performance headaches.
After initial rendering, you can basically go with pure TypeScript/DOM APIs to mutate the DOM wherever and whenever it is actually needed - not when the framework thinks it's needed.
However there is...
...to make your life easier :-)
Thank you so much for supporting us financially! 🙏🏻😎🥳👍
|
Tom |
SpringType is brought to you by:
|
Aron Homberg |
Tom |
Michael Mannseicher |
Please help out to make this project even better and see your name added to the list of our CONTRIBUTORS.md 🎉
| Back | FazBrowse Home | New Git URL |