r/reactnative • • May 30 '20

Rough.js bindings are now available for React Native. ✍️(source in comments)

228 Upvotes

16 comments sorted by

7

u/masocs May 30 '20

Nice lib

3

u/cawfree May 30 '20

Thanks dude, really appreciate it. 👊

3

u/x_OMEGA_x May 30 '20

good job mate. Really good

1

u/cawfree May 30 '20

Thanks a lot! Your feedback makes it all worth doing. :)

3

u/richpeopleshit May 31 '20

Dude yes! I was trying to implement this last week in React Native. I got stuck and couldn't get it working properly. I was planning on picking back up at some point but now I'm happy to see you've done this!

1

u/cawfree May 31 '20

Ah that’s great, really glad to help! 🥳🥳🥳

2

u/vertigo_101 May 31 '20

Great job as always mate

2

u/cawfree May 31 '20

Thanks a lot! You're the best, K! 👊

2

u/GreatCosmicMoustache May 31 '20

Great job! Random question, what is the pattern that let's you make "namespaced components", for lack of a better word? The <Rough.ComponentName> thing

2

u/cawfree May 31 '20

Thanks very much! I export default a frozen object which contains all of the components. You can see this here!

1

u/GreatCosmicMoustache May 31 '20

Great stuff, thanks a lot! I've been wondering about that for a good while now

2

u/moondaddi80 Jun 02 '20

Awesome work.

1

u/cawfree Jun 02 '20

Thanks a lot! Hope this helps you out! 🥳👊

5

u/[deleted] May 30 '20

[removed] — view removed comment

6

u/cawfree May 30 '20

I'm really glad you think so! Thanks a lot.

Originally, I was under the impression that the rendering was something proprietary to Excalidraw, until I randomly happened upon this tweet. As soon as I saw that it was open source, I just had to get it into React Native. I remember so many times over the past couple of years where I would have loved to have had some hand-drawn effects, so better late than never!

Honestly, the real magic behind the integration is that Rough.js was designed extremely well.

I thought it would have been much harder, and require a lot more cherry picking, because usually libraries like this are very tightly coupled to the DOM.

But, we were lucky. Rough.js exposes an extremely useful class called RoughGenerator which is pure business logic, a high level interface, and just returns SVG parameters which are directly compatible react-native-svg. I believe this has come about because the original library offers a way to target either the DOM directly, or an svg node. I think this requirement introduced the perfect level of abstraction for us to hook into. :)