Do you mean this? I think it's just another one level of bureaucracy. The only difference is that you cannot do this with the wrapper:
onChange(prevValue=>...)
But if you use TypeScript and will declare prop-type like:
onChange:(newValue:stirng):void
you would not be able to do it anyway
I think it's more than "okay" to pass setters below the tree. And it doesn't violate top-down principle. The parent component in both cases is the only source of truth. And the only way to change the state is to use those tools that parent components provide to its children.
P.S. also if you're interested in strong performance you will wrap you wrapper by another wrapper (useCallback) :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Mydrax:
Do you mean this? I think it's just another one level of bureaucracy. The only difference is that you cannot do this with the wrapper:
But if you use TypeScript and will declare prop-type like:
you would not be able to do it anyway
I think it's more than "okay" to pass setters below the tree. And it doesn't violate top-down principle. The parent component in both cases is the only source of truth. And the only way to change the state is to use those tools that parent components provide to its children.
P.S. also if you're interested in strong performance you will wrap you wrapper by another wrapper (useCallback) :)