I am trying to get the width of the ref DOM element and set state to use in the render component. The problem arises because this width changes when the user enters, and when I try to execute setState inside componentDidUpdate , it starts an infinite loop and my browsers bomb.
I created the fiddle here http://jsbin.com/dizomohaso/1/edit?js,output (open the console for some information)
My thinking was:
Component mounts, setState: refs.element.clientWidth
User enters data, render triggers
shouldComponentUpdate returns true only if new.state not equal to old.state . My problem is that I'm not sure where it makes sense to update this state ?
Any help would be greatly appreciated, thanks for reading!
Rave.
source share