williamcotton.com
react-use-c
williamcotton.com | react-use-c | |
---|---|---|
1 | 2 | |
2 | 539 | |
- | - | |
7.9 | 6.0 | |
22 days ago | 7 months ago | |
F# | JavaScript | |
- | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
williamcotton.com
-
React Use C
These conditional checks are an obvious sign that they’ve cleaved the rock in the wrong location.
These conditional checks on server state exist because they didn’t create the shared environment between web server and web browser at deep enough of a level.
The key is to replicate the server-side pattern of “user actions cause HTTP request”. That is, you make a version of express that runs in the browser. Then you make parallel middleware that runs in both the browser and the server. Then you make your React components fire off mock HTTP requests that are handled by the browser express router.
So you write the same route handlers and components for the browser and server to run but then you write environment specific middleware.
Browser middleware:
https://github.com/williamcotton/williamcotton.com/tree/mast...
Server middleware:
https://github.com/williamcotton/williamcotton.com/tree/mast...
I’ve expanded beyond express in the above application to add controllers, a routes file, and views, all code that has no conditionals and runs in both the browser and server environment.
What NextJS demoed is poorly conceived. There’s no need to autogenerate a link to an API.
Instead, your frontend middleware has req.update() defined to make an API request and the server middleware has req.update() defined to make the SQL update.
And there you go, sane server and client side rendering.
react-use-c
What are some alternatives?
react-use-rust - Use Rust in your React!
picoc-js - The picoc interpreter compiled as WASM.
lambda-8cc - x86 C compiler written in untyped lambda calculus