-
Notifications
You must be signed in to change notification settings - Fork 1
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
Attempt at supporting shorter syntax #2
Conversation
Refactor to avoid the user needing to pass a function
Ah! 🤦♂️ I've just worked out that problem 2 above is nonexistent! This already works: // before
let%Epitath {pageX, pageY} = children => <OnLayout callback=Js.log> ...children </OnLayout>;
// after this PR
let%Epitath {pageX, pageY} = OnLayout.make(~callback=Js.log); So the only downside remaining is the lack of JSX syntax. |
amazing @benadamstyles , sorry the delay to comment. |
Cool 🙂 the only thing is the inability to pass |
Me neither @benadamstyles |
I like this. |
Well, so it's a go! |
Thanks for your contribution @benadamstyles, will release soon to npm |
@benadamstyles we are thinking in keep both syntaxes and call this one other |
Hey, yep seems like a good idea to keep both syntaxes, for those who prefer JSX visually. Does zombie have a meaning in programming already? Thinking of “zombie processes”. Just wondering about choosing a term with fewer existing connotations! |
What about just |
Makes sense also! we could even go furthe |
Yep! Although as module names are global, maybe that’s a little risky? |
|
Fixes #1
This is just an exploration, to test the limitations of what could be achieved. The problem with the JSX syntax is that using JSX calls
ReasonReact.element
, which meansbs-epitath
doesn't get the opportunity to pass in the render prop function, hence why currently the user must declare a function.In this attempt, I assumed 2 limitations:
let%Epitath
binding (i.e. we are aiming at a shorter syntax).let-anything
ppx, we musn't require a further ppx.The only solution I could think of was this PR, where the user simply passes the component's make function and it's up to
bs-epitath
to callReasonReact.element
with that make function and also pass in the render prop function. (NB I switched round the meaning ofchildren
in this PR because it didn't make sense to me thatchildren
referred to the render prop component andrender
referred to thechildren
function!).This is the diff of usage:
There are 2 issues with this solution, however:
children
prop. There might be a way around this!