When I try to create a text field that change h depend on w
so I define elem.props.w and elem.props.h,
If I use useEffect to update h by w, and the draw function is like
function (self, x, y, w, h)
self.props.w=w
...
end
And finally I want to call elem:render(x, y, w, elem.props.h)
These code I have some problems:
- Before first render,
props.h is nil, so I have to set a default value.
- The update is after this frame, this can cause some problem if I have chain of update.
So I wonder, maybe it can be solved by add prerender function to do something before render?
When I try to create a text field that change
hdepend onwso I define
elem.props.wandelem.props.h,If I use
useEffectto updatehbyw, and the draw function is likeAnd finally I want to call
elem:render(x, y, w, elem.props.h)These code I have some problems:
props.hisnil, so I have to set a default value.So I wonder, maybe it can be solved by add prerender function to do something before render?