In react-opal, you can use the React context feature, like this. I can probably do a PR for this.
class ParentComponent
include React::Component
# Simply supply the Ruby/Opal type that :foo will be and react-opal will map that to a React PropType automatically
provide_context(:foo, Fixnum) { params[:foo_value] }
def render
present ChildComponent
end
end
class ChildComponent
include React::Component
consume_context(:foo, Fixnum)
def render
# will render the :foo_value prop passed into ParentComponent
div { "foo is #{self.context[:foo]}" }
end
end
In react-opal, you can use the React context feature, like this. I can probably do a PR for this.