Skip to content

Add callback validation to fiber-based renderers - #8677

Merged
bvaughn merged 1 commit into
react:masterfrom
bvaughn:add-callback-validation-to-dom-render
Jan 3, 2017
Merged

bvaughn merged 1 commit into
react:masterfrom
bvaughn:add-callback-validation-to-dom-render

Conversation

@bvaughn

@bvaughn bvaughn commented Jan 3, 2017 •

Copy link
Copy Markdown
Contributor

Moved ReactFiberClassComponent validateCallback() helper function into a standalone util used by both fiber and stack implementations. Validation now happens in ReactFiberUpdateQueue so that non-DOM renderers will also benefit from it.

This fixes 2 failing fiber tests.

@gaearon

gaearon commented Jan 3, 2017

Copy link
Copy Markdown
Collaborator

Nit: can we also change Stack to use it?

@bvaughn

bvaughn commented Jan 3, 2017

Copy link
Copy Markdown
Contributor Author

Yeah, I was already making that change. 😁 Realized they were super redundant after I pushed the Fiber change.

@acdlite

acdlite commented Jan 3, 2017

Copy link
Copy Markdown
Collaborator

It's only ever used in ReactFiberUpdateQueue. We should just move the validation to there, like in Stack.

@bvaughn

bvaughn commented Jan 3, 2017

Copy link
Copy Markdown
Contributor Author

It's only ever used in ReactFiberUpdateQueue. We should just move the validation to there, like in Stack.

I don't understand your comment @acdlite.

@acdlite

acdlite commented Jan 3, 2017 •

Copy link
Copy Markdown
Collaborator

To clarify: rather than validating separately in ReactFiberClassComponent and ReactDOMFiber, move the validation to ReactFiberUpdateQueue.

@acdlite

acdlite commented Jan 3, 2017

Copy link
Copy Markdown
Collaborator

There's nothing renderer specific about validateCallback so we want all renderers to have top-level callback validation, not just the DOM renderer.

@bvaughn
bvaughn force-pushed the add-callback-validation-to-dom-render branch from 5559da7 to 8d9a1ad Compare January 3, 2017 19:27
@bvaughn

bvaughn commented Jan 3, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying @acdlite. That's a nice improvement since it will also add callback validation for other renderer types.

This PR has been updated with that change.

@bvaughn bvaughn changed the title Add callback validation to ReactDOMFiber.render Add callback validation to fiber-based renderers Jan 3, 2017
//
// If the update is cloned, it returns the cloned update.
function insertUpdate(fiber : Fiber, update : Update, methodName : ?string) : Update | null {
function insertUpdate(fiber : Fiber, update : Update, methodName : string) : Update | null {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since methodName is now always a string, we can remove the typeof check on line 215.

@acdlite acdlite left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@acdlite acdlite added this to the 15-next milestone Jan 3, 2017
@bvaughn
bvaughn force-pushed the add-callback-validation-to-dom-render branch from 8d9a1ad to bc05ef1 Compare January 3, 2017 19:33
formatUnexpectedArgument(callback)
);
},
validateCallback: validateCallback,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this indirection useful? Can we just import it directly in the calling file instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't! Good catch. Removed. 😄

Moved ReactFiberClassComponent validateCallback() helper function into a standalone util used by both fiber and stack implementations. Validation now happens in ReactFiberUpdateQueue so that non-DOM renderers will also benefit from it.
@bvaughn
bvaughn force-pushed the add-callback-validation-to-dom-render branch from bc05ef1 to 8fbcd49 Compare January 3, 2017 20:10
@bvaughn
bvaughn merged commit b27cb2c into react:master Jan 3, 2017
@bvaughn
bvaughn deleted the add-callback-validation-to-dom-render branch January 3, 2017 22:57
@sebmarkbage

Copy link
Copy Markdown
Contributor

Another one we can easily make a warning. Should we do a pass through and see how many of these we can make into warnings to help file size?

@sebmarkbage

Copy link
Copy Markdown
Contributor

Nit: Same as #8639 (comment)

@gaearon

gaearon commented Jan 11, 2017

Copy link
Copy Markdown
Collaborator

Should we do a pass through and see how many of these we can make into warnings to help file size?

Yes, I'll add to umbrella.

mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
…-dom-render

Add callback validation to fiber-based renderers
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
…-dom-render

Add callback validation to fiber-based renderers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants