react.rb icon indicating copy to clipboard operation
react.rb copied to clipboard

React::NativeLibrary for re-using JS based react components

Open barriehadfield opened this issue 8 years ago • 2 comments

Not so much an issue as a feature request, but I am looking for a clean natural way of re-using JS based React components alongside ruby based JS components.

In trying to get this to work, I have been using React::NativeLibrary as a base class then importing the JS component but this does not work as React::NativeLibrary expects a JS library not a react component.

The code I would like to write is something along these lines:

class TimeAgo < React::NativeLibrary # something to import a JS based react component (*react timeago in this example) end

And then to use this something like:

TimeAgo(date: "Jan 1, 1990") {}

Many thanks!

  • https://www.npmjs.com/package/react-timeago

barriehadfield avatar Apr 08 '16 12:04 barriehadfield

PS: I have written up the issue on StackOverflow and also added a workaround here: http://stackoverflow.com/questions/36466338/how-do-i-import-a-javascript-or-jsx-based-component-into-react-rb-so-it-is-acces/36499842#36499842

barriehadfield avatar Apr 08 '16 12:04 barriehadfield

This issue was moved to reactrb/reactrb#139

sollycatprint avatar Jun 13 '16 13:06 sollycatprint