javascriptrubyreactjsopalrbhyperstack

Can I make a functional component in Hyperstack?


All of the documentation refers to creating components using classes. Can I make a functional component in order to leverage react hooks, and if so, how?

To clarify, I can only find documentation for creation a class based component like

class Example < HyperComponent
  render do
    DIV { "Example" }
  end
end

Which would be equivelent to

class Example extends React.Component {
  render() {
    return <div>Example</div>
  }
}

I want to recreate the following:

() => {
  return <div>Example</div>
}

Solution

  • No, you cannot. See https://github.com/hyperstack-org/hyperstack/issues/167 for why. Basic answer: the Hyperstack DSL already solves the major issues solved by functional components, and the negatives of adding functional components (there are some) then outweigh any advantages.

    Note that you can import functional components from JS libraries just fine.