7 ms·
Does that render() call in the useState function would still render the changed elements only?
by leowoo91 7y ago
Does that render() call in the useState function would still render the changed elements only?
- lxe 7y agoNo, 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-reconciler/src/ReactFiberHooks.js#L169-L178 https://github.com/facebook/react/blob/master/packages/react...)
- leowoo91 7y agoThat 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)
- nohuhu 7y ago(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 https://github.com/riptano/statium RealWorld example: https://github.com/nohuhu/react-statium-realworld-example-app https://github.com/nohuhu/react-statium-realworld-example-ap... Sorry... Just... Couldn't... :)