Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

validateProps for new reconciler #174

Merged

Conversation

AmaranthineCodices
Copy link
Contributor

@AmaranthineCodices AmaranthineCodices commented Dec 18, 2018

Supersedes #94; closes #24. Functionally the same as #94, but for the new reconciler instead! Briefly, this adds a new static method to components:

static validateProps(props: table) -> (false, message: string) | true

Every time props are updated, validateProps will be called with the new props before shouldUpdate and init are called. validateProps returns the same parameters that assert expects: a boolean, true if the props passed validation, false if they did not, plus a message explaining why they failed. If the first return value is true, the second value is ignored.

This is intended to be used with a type checking library like PropTypes or t.

One question remains about this: should this use GlobalConfig to conditionally disable it? I know we're looking to move away from GlobalConfig, so I'm not sure!

Checklist before submitting:

  • Added/updated relevant tests

This was referenced Dec 18, 2018
@AmaranthineCodices
Copy link
Contributor Author

New concern: is there a better/shorter name than assertCalledWithDeepEqual?

Copy link
Contributor

@ZoteTheMighty ZoteTheMighty left a comment

Choose a reason for hiding this comment

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

As discussed, we'd like to hide this behind a GlobalConfig flag that defaults to false.

@ZoteTheMighty ZoteTheMighty merged commit c70a457 into Roblox:new-reconciler Mar 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants