towards react-16
coot opened this issue · 5 comments
coot commented
React 16 will allow to return arrays (or maybe even more general iterators) from within render method. We can have a few choices how to support that.
- using variants in render codomain
- or adding a function of type
wrap :: Array ReactElement -> ReactElementwhich would be justunsafeCoerce
The second choice would easier to adopt in existing projects, the first one would break a lot of classes. We could add a new type to avoid that though.
paf31 commented
Another option is to make the type of render polymorphic in the spec type, and then to use a type class (with no members) to constrain the return type.
coot commented
Do you mean sth like this:
class ReactRender a
instance arrayReactRender :: ReactRender (Array ReactElement)
instance reactElementReactRender :: ReactRender ReactElement
-- | A render function.
type Render props state render eff =
ReactThis props state ->
Eff
( props :: ReactProps
, refs :: ReactRefs Disallowed
, state :: ReactState ReadOnly
| eff
) render
spec :: forall props state render eff.
ReactRender render =>
state -> Render props state render eff -> ReactSpec props state render eff
The problem with this approach is that it's not backward compatible, but maybe that's fine.
suzumiyasmith commented
"Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see https://fb.me/react-create-class"
And I got this warning while running js generated by thermite.
paulyoung commented
@suzumiyasmith I think that should have been addressed by #99