-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve types for animation hooks etc. #1612
Improve types for animation hooks etc. #1612
Conversation
Hmm, doing that breaking change aint good idea IMO. It doesnt benefit much, render method in inferno also has nextProps available so its not a big deal |
@@ -206,7 +206,6 @@ export function moveVNodeDOM(parentVNode, vNode, parentDOM, nextNode, animations | |||
|
|||
if (flags & VNodeFlags.ComponentClass) { | |||
refOrInstance = vNode.children; | |||
instanceProps = vNode.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm? Why was this line removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't pass instance props to a Component Class since we don't do it in the other hooks (correct me if I am wrong), so I wanted to remove this inconsistency because it could cause confusion. See:
componentDidMount?(): void;
componentWillMount?(): void;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whereas I agree that breaking changes are bad, consistency is worth a lot, I think it is better to clean up the API early. We still have very few downloads of v8 and changing from props
to this.props
is intuitive. However, just updating the type definition and leaving this row would nudge people in the right direction by only throwing a type error. Then we could remove it in v9 (if we remember).
nextProps
is different, because there you access current props with this.props
too.
@Havunen what is your take on props having different types for Class Components and Function Components? Fix or don't fix?
|
Props should have children property defined in its type |
I think we should add context to onComponentWillUpdate too |
Will fix
Will fix I'll need a couple of days until I have completed this. |
@Havunen I have made the changes EXCEPT adding context to the on[xxx]Update hooks. That change broke tests and they are used both in normal and compat mode. In compat mode we don't send context (since React didn't) and I ran out of time figuring out what to change, so I backed out on the context change. |
Great! Can you fix the conflict please :) |
…props to method on Class Component (componentWillMove)
…onentWillMove. It should be referenced using this.props. This was implemented inconsistently with the other Class Component animation hooks and I think it is better to fix it now than have it linger. Worth a bump in minor version.
82f1247
to
502afcb
Compare
@Havunen PR rebased on master. Didn't run prettier at the end because there were many files affected that I haven't worked on. Better to run prettier separately on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR
The typing for animation hooks was incomplete:
componentWillMove
hookHTMLElement | SVGElement
componentWillMove
hook (it is inconsistent with the other hook, props should be referenced usingthis.props
)NOTE: The last change is a BREAKING CHANGE, but I think it is better to fix it now than have it linger. Worth a bump in minor version.
While implementing this I also noted the following inconsistency in typing of argument props:
Where
children?
is only added for class component hooks.Let me know if I should change this.