
React SVG Drawing Library - kmkzt927
https://github.com/kmkzt/react-hooks-svgdrawing
======
anty
As someone learning React atm: Why is this developed as a hook, and not as a
component?

~~~
k__
Seems like it does the drawing outside of React.

It takes a ref to a React rendered DOM element and then does its thing.

~~~
anty
Yes, but you could do that in a component as well?

~~~
k__
Sure, but I guess it's more flexible that way?

~~~
anty
Okay, I guess you could attach that functionality to an existing component. It
just feels wrong to me, that you would put something that looks like a
separate component into a hook to inject into another component. I thought
there was some benefit in doing it like this, that I cannot think of...

~~~
k__
The main goal of React hooks was the shrinking of the component tree. Most
people would probably create their own version of an SVG component and then
they would have to nest the library component. Now they just have to throw in
the hook and be done with it.

------
ralusek
This is just a react hook wrapped around two.js

------
IceDane
What are the benefits of this supposed to be, exactly? Svg elements can be
rendered like any other HTML element in react, and manipulated as components
and what not. Why would I want to pull in this dependency which seems to
consist of 50 lines of code?

What is up with the tendency to think that any semi-neat abstraction you come
up with needs to be its own library?

------
nullandvoid
Was playing around with 2 in 1 laptops the other day using paint. This feels
considerably more snappy on my 4 year old s7 phone which is impressive

------
th0ma5
I like the palette on the demo!

~~~
akx
They're entirely random colors... [https://github.com/kmkzt/react-hooks-
svgdrawing/blob/eea6349...](https://github.com/kmkzt/react-hooks-
svgdrawing/blob/eea63497fc14e12e88f144eaf7187e9959e7589d/src/example/index.tsx#L13-L16)

