Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does that render() call in the useState function would still render the changed elements only?


No, render is global in this example. If you need to only render the component wrapping the useState, you have to track the caller (See https://github.com/facebook/react/blob/master/packages/react...)


(shameless plug!)

... or you can use something like Statium's ViewModel, which is basically a hierarchically linked, locally scoped state container component: https://github.com/riptano/statium

RealWorld example: https://github.com/nohuhu/react-statium-realworld-example-ap...

Sorry... Just... Couldn't... :)


That is interesting, earlier I enabled flash painting in your codepen and it only re-rendered/flashed the specific component that has a value changed. Maybe that was a browser feature (safari) I will look into tracking to understand what you mean.. (or maybe it's a coincidence it works as expected)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: