Skip to content

Instantly share code, notes, and snippets.

@chadwilken
Created April 12, 2018 02:11
Show Gist options
  • Save chadwilken/a3f370a59a44ca1912dc691c44912708 to your computer and use it in GitHub Desktop.
Save chadwilken/a3f370a59a44ca1912dc691c44912708 to your computer and use it in GitHub Desktop.
module ReactHelper
def react_component(name, props: {}, html_class: nil)
content_tag(
'div',
nil,
class: html_class,
data: { controller: 'react', 'react-component' => name, 'react-props' => react_props(props) }
)
end
def react_props(**args)
return nil if args.nil?
JSON.dump(args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment