-
Notifications
You must be signed in to change notification settings - Fork 65
Type of children
prop field should dictate the value used in createElement
#164
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
Comments
The reason why |
Okay, so, let me get this straight. Under-the-hood,
Would that include
Awesome, makes perfect sense.
Okay, so from this use case, you're expecting to use a purescript-engineered React component from the regular React workflow in JavaScript? That makes good sense for why
Okay, here's where I'm lost. How would you just have "parametric children", when the type signature of I am trying to bring proper type safety for the usage of children from within PureScript, using a PureScript engineered React component, inside another PureScript engineered React component. Again, my primary use case for this is a
|
|
createLeafElement someContext.consumer { children: \value -> ... } |
I don't think this is how React was intended to be used though... from what I understand, the |
Yes, it works, and we use it quite frequently. |
I guess that depends on what it is 😆 I don't agree that the current API does not reflect the intended usage, since the intended usage (JSX) does not apply to us. For me personally, I think it's important that we do not use anything other than a trivial |
Overall, I would much prefer to use #152, but I would need to use it first. I personally don't care about React's dev validation since I have a type system, but I would be concerned about adopting it in the library without observing that actual effects. |
Hmm okay, I'm sold :) sorry about the gripes, I just feel like the current API is just a bit unintuitive on how it should be used. How about some documentation patches? |
Thanks for bringing this up. If you are interested in adding/updating documentation or examples in the README, a PR is certainly welcome. |
Awesome! I just submitted it. Thanks for your help @natefaubion! |
* semicolons * exposing `fragment`, fixing doc typos, adding docs in regards to #164 * better README * typo
Firstly, I think we should do-away with the
Children
foreign data type, which aims to represent the prop field. It's opaque, and doesn't accurately represent the purpose of the prop type.The existence of the
children
prop, in React's perspective, means that the component should be treated as one that can have children (i.e.<Foo> ... </Foo>
, rather than<Foo />
).I believe the
createElement
function should have a type similar to(more or less, disregarding the
ReactPropFields
constraint). This would allow for natural semantic consistency with React 16.x'sContext
, where aConsumer
has a children prop ofchildren :: a -> ReactElement | ...
.Furthermore, unitary components (i.e.
<Foo />
) would be created with a different functionstrictly because the ReactClass's props lacks the
children
attribute.This way, the
children
attribute's value could just be coerced by its usage increateElement
, whether it be an array of ReactElements, a single ReactElement, a fragment or whathaveyou. But more consistently, as a function for a Context'sConsumer
, making the paradigm more readily available for end-users.The text was updated successfully, but these errors were encountered: