我可以在Hyperstack中创建一个功能组件吗?

问题描述 投票:1回答:2

所有文档都涉及使用类创建组件。我可以制作一个功能组件以利用反应钩子,如果是这样,怎么做?

为了澄清,我只能找到创建基于类的组件的文档

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

这相当于

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

我想重新创建以下内容:

() => {
  return <div>Example</div>
}
javascript ruby reactjs opalrb hyperstack
2个回答
1
投票

你不能。请参阅https://github.com/hyperstack-org/hyperstack/issues/167了解原因。基本答案:Hyperstack DSL已经解决了功能组件解决的主要问题,添加功能组件(有一些)的负面影响超过了任何优势。

请注意,您可以从JS库中导入功能组件。


0
投票
example = Example().as_node
# then you can do
example.render 
# or anything else you want with the example object
Another(example_component: example) # to pass it as a param
© www.soinside.com 2019 - 2024. All rights reserved.