Skip to content

Can't use different ReactRender types in render #131

Closed
@natefaubion

Description

@natefaubion

The polymorphism over render with ReactRender lets you use different return types, but it's fixed for the class, which means you can't return different types on different ticks of render. I should be able to return a String in one render tick, and a ReactElement in another tick. The correct type I think would be:

{ ... render :: forall r. ReactRender r. ReactThis props state => Eff ... r }

Edit: This is actually wrong, since it means render can't fix the type.
But this higher-ranked type is problematic. I think instead we should just define coercions to ReactElement, since these can actually be used anywhere and not just the root of a render.

fromString :: String -> ReactElement
fromInt :: Int -> ReactElement
fromNumber :: Number -> ReactElement
fromArray :: Array ReactElement -> ReactElement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions