Live data from Hacker News

Ask HN: How can we make React better?

news.ycombinator.com

31–40 of 68 posts

Re: Ask HN: How can we make React better?

#31
I wish non-css animations were easier!

If you have any animation where you want to tween the state yourself (say changing position as a function of time), then that requires updating the state at 60fps or whatever requestAnimationFrame goes at.

It feels philosophically wrong to do that under the declarative paradigm of react. React is supposed to be responsible for taking the state and "transitioning"(or diffing) the dom to the new state. By doing the tweening myself, it feels like I am polluting the state with a lot of transient junk (like current progress time, start/end keyframe states, entering/exiting elements, etc). This is especially bad if you want to be a redux purist and throw all my state into a global state! But at the same time I don't know where else I can put it.

I've completely avoided doing anything more complicated than a CSS transition since coming to react (long ago, which also means there could be better 3rd party libraries that solves this problem now that I don't know of). But is there a better way to make this work out of the box?

Re: Ask HN: How can we make React better?

#32
post #31

I wish non-css animations were easier! If you have any animation where you want to tween the state yourself (say changing position as a function of time), then that requires updating the state at 60fps or whatever requestAnimationFrame goes at. It feels philosophically wrong to do that under the declarative paradigm of react. React is supposed to be responsible for taking the state and "transitioning"(or diffing) the…

It may feel excessive to rerender an animating component every animation frame, but in practice it’s generally “fast enough” and I find the declarative programming model very nice to grasp mentally.

Regarding the handling of timers, easing functions, etc., that does need to be handled somewhere, but it can be “componentized” so that you can reuse animation logic via a friendly component API without worrying about the underlying bookkeeping. You’ll have to learn and get used to that API, but when you find one that works for you it can be great. Two popular such libraries for React are react-spring and Pose:

http://react-spring.surge.sh/spring

https://popmotion.io/pose/learn/popmotion-get-started/

Re: Ask HN: How can we make React better?

#36
post #13

At this point, I'm quite satisfied with React and use it for most of my new JavaScript UIs. A few potential improvements that come to mind: 1. More strictness in terms of what is and is not valid JSX. Just today I was working on a React Native app that compiled for iOS but not Android. The issue ended up being a stray semicolon, leading to syntactically incorrect code that allowed for a valid iOS build anyway. I woul…

Have a look at reason-react, the compiler will find all syntax errors

Re: Ask HN: How can we make React better?

#37
Some other comments also touched on this, styling remains my biggest pain using react (I made or worked on a dozen react projects of varied sizes).

I wish for media queries and keyframes (and other CSS tidbits) to be possible in React JS styles, so that I stop hopping between different CSS module libraries.

Re: Ask HN: How can we make React better?

#38
I kinda enjoy working with React (because of JSX simplicity and composability). I think you could add easy support for some styling solution like it's done in Vue.

I would focus on making React stable, fast and lightweight but improve on tooling and ecosystem around it.

* I would like blessed way of extracting React components, so they can be reused between projects (like right click in IDE and share) - something like https://bitsrc.io/

* react addon for chrome could be much nicer (I have to dig through so many unnamed HoC sometimes).

* you could favor more beginner friendly state solution - something like https://github.com/solkimicreb/react-easy-state

* you could embrace typescript for easier usage experience

There could be some React plugin(kinda like http://demo.rekit.org/) for editors that would allow for:

* adding mock props to component and preview it on hover, click for example (kinda like styleguidist but with less setup overhead) * abuse above to provide out of the box image snapshot testing * simpler ability to add tests (like right click on component and "add assertion", "go to test") * some structured way of making components * swap between style, tests, data sources and logic * run tests only for this component * etc - basically more streamlined creation experience

Also please focus on debugging when introducing async rendering. (so there won't be errors out of nowhere in stack trace)

Re: Ask HN: How can we make React better?

#39

I kinda enjoy working with React (because of JSX simplicity and composability). I think you could add easy support for some styling solution like it's done in Vue. I would focus on making React stable, fast and lightweight but improve on tooling and ecosystem around it. * I would like blessed way of extracting React components, so they can be reused between projects (like right click in IDE and share) - something lik…

typescript++
Post reply on HN