-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ideas #1
Comments
Thanks for the detailed suggestion! yield without functionWe had discussed this before here and we feared that it would add implicitness with cloneElement, though I agree it gets easier to read and helper beginners to relate it with "await". Name changeI really liked the "Renderator" name. What do you guys say @Astrocoders/core? Let's rename it to Renderator? [Edit] Just looked and Formik also allow a |
I don't think most people would even notice unless already know in detail how React elements work
I would just enforce the use of function Wrapper(props) {
return <Original {...props} render={props.children}/>
}
function* Example() {
let { state } = yield <Wrapper/>;
// ...
} |
Makes sense and look cleaner indeed, gonna be pushing this soon! |
one issue with: // before:
let { time } = yield props => <Time {...props}/>;
// after:
let { time } = yield <Time/>; is that flow and typescript will both complain if |
@phpnode, Generators are not well supported by type systems, anyway, though... I.e. Typescript will not be able to tell you what the type of |
I really like what you've done with regenerator, I've been playing around with some ideas:
https://github.com/jamiebuilds/renderator
yield <Component/>
By leveraging
React.cloneElement()
you can eliminate the extra functions being created in each yield:Instead of switching on
typeof value === 'function'
you can switch on immutagen'scontext.next
function being non-existant. Then modify the props of thecontext.value
withReact.cloneElement
I think it would be good to do this because it requires a lot less typing and is a lot easier to read.
displayName
You can make the returned component look better in React DevTools by providing a
displayName
which wraps the previous generator's name:Rename regenerator
Regenerator is already a super similar project which is in wide use. It's actually a requirement to use
@astrocoders/regenerator
if you want to transform generators functions for the browser today because it's what Babel uses.I think this project would do better if it had a name that was more accessible. You've got some great words to play with too. The
-rator
fromgenerator
lets you do fun stuff. My first idea was "Renderator"React RFC
I think I'm going to turn this into an RFC for React to add it directly.
Someone on the React team (I forget who) already brought up potentially adding a syntax like this.
The text was updated successfully, but these errors were encountered: