Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intro
This feature introduces a reactive components style (like it Recks) with React's hook API available:
Here's an example using react-router useParams hook with data fetching:
And here's a small app, made with
createComponent$
: https://stackblitz.com/edit/react-rxjs-elements-components-alphaAPI
react-rxjs-elements
now additionaly exposes:createComponent$(fn: (props$: Observable<Props>) => JSX | Observable<JSX>)
-- create a stream componentuseHook$(fn: () => any)
-- use a React hook (or any 3rdparty hook) inside a stream componentuseMount$()
anduseUnmount$()
-- both return: Observable<void>
. Predefined hooks that will emit a void value when the component is mounted and unmountedTry it
This feature is available in the
@next
version of this library and currently can be tried vianpm i react-rxjs-elements@next
or at stackblitz playground online.Please, share your thoughts and feedback in this thread -- this helps a lot!
Have a good day :)