-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Currently frender and react-rs rely on react-sys to work.
react-sys uses a feature flag import-react to control whether to import from react module or just use global variable React.
A better design could be as following:
frender and react-rs shouldn't rely on any runtime implementation details (e.g. where React is imported).
Instead, they provide a trait ReactRuntime defining common behaviors.
For libraries, they also rely on the ReactRuntime trait to call hooks and create elements.
For binaries, only at frender::main or the beginning of main fn should the runtime be specified globally.
Going further, there could be a pure rust implementation of the runtime, which is independent of wasm-bindgen and can run in server side. (SSR might be implemented with this)
frender is at v1-alpha versions. BREAKING CHANGES are unavoidable to apply the new design. But I will make as least BREAKING CHANGES as possible with the following todos:
- In
react-rsandfrender, wasm-bindgen and other wasm-related dependencies should be under optional featurejs.- Some
impl AsRef<JsValue>must be removed as they no longer contain JsValue. -
Into<JsValue>can only be implemented with featurejs.
- Some
- In
react-rs, provideRuntimetrait, which defines common behaviors of React runtime.-
react-rsshould maintain a thread_local static cell of runtime instance and this can be set once (maybeOnceCell<Box<dyn Runtime>>) -
frendershould re-pubreact::RuntimeasReactRuntime
-