
Crank: JSX-driven components with functions, promises and generators - redonkulus
https://crank.js.org/blog/introducing-crank
======
WorldMaker
This seems a very useful counter-argument to the current React "orthodoxy".
I'm curious to see where this goes over time.

If I may offer two big pieces of advice towards either adoption or truly
making a statement that React might have to react to:

1\. You probably need to answer the questions:

A. How do I use an existing React component? B. Can I use a component written
in this inside of a React application?

If you can find a really good answer to either of these, and especially if you
have a good answer for both, you can help get adoption. With as large as the
overall React ecosystem is, it's going to be tough for any and all React-likes
to gain traction without some sort of compatibility story. You don't have time
for the React world to stop.

2\. Testing. Probably the biggest contributor to the "components should be
pure functions" orthodoxy in React comes from a well intentioned perspective
of testability. Pure functions are indeed easy to test. It is easy to forget
that they aren't always the only thing easy to test. I see you've got some
tests for Crank.js itself in the GitHub repository, that's a great first step.
I think you would make a stronger statement _to_ the React orthodoxy if you
added (and focused) documentation on testing each style of component.

I know from some experience there are some very good ways to test generators
and even async generators. If you can show it and make it seem easy (because
it should be), that could especially go a long way to saying why Suspense
especially in trying to adhere to an early approach to keeping testing simple
has in some ways pushed testing really complex.

So far as I can see the potentially most complicated part of testing will be
how easily can you mock the `this` context. Should be something that is easy
to build a reusable test context. Here too it should be possible to remind
people that testing a custom function context should be as simple as
`MyComponent.bind(testContext)` or `MyComponent.apply(testContext,
{...props})`.

The more you can prove that testing all flavors of components here is simple
to do, the more you might help assuage doubts that these aren't "pure"
functions.

