From e94e4253a2b8ddbfcc30c46cbdb6848acaf7d04e Mon Sep 17 00:00:00 2001 From: Aaron Lademann Date: Wed, 17 Jul 2024 11:33:08 -0700 Subject: [PATCH] Improve decision tree --- doc/null_safety/null_safe_migration.md | 33 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/null_safety/null_safe_migration.md b/doc/null_safety/null_safe_migration.md index 2bff6d52b..e2567f326 100644 --- a/doc/null_safety/null_safe_migration.md +++ b/doc/null_safety/null_safe_migration.md @@ -127,18 +127,29 @@ Below is a table of the possible options for prop nullability: > components since it will automate the vast majority of this process. ```mermaid +--- +title: Should My Prop Be Required? +--- flowchart TD - Start[Should My Prop Be Required]==>HasDefault - HasDefault((Does the \nprop have a \ndefault value?))== Yes ==> Defaulted - Defaulted((Where is \nthe default?))-- defaultProps getter\n(Class Component) --> End_Defaulted1[/"Make it required\nlate SomeType propName;"\] - Defaulted-- local var\n(Function Component) --> End_Optional1[/"Make it optional\nSomeType? propName;"\] - HasDefault == No ==> NotDefaulted - NotDefaulted((Is it set \nfor every \ninvocation?))-- No --> End_Optional2[/"Make it optional\nSomeType? propName;"\] - NotDefaulted-- Yes --> AlwaysSpecified - AlwaysSpecified((Is the prop \npublic API?))-- Yes --> PublicAlwaysSpecified - PublicAlwaysSpecified((Is the prop mixed in \nby any other component?))-- Yes --> End_PublicAlwaysSpecifiedMixedIn[/"Make it optional\nSomeType? propName;"\] - PublicAlwaysSpecified-- No --> End_PublicAlwaysSpecifiedNotMixedIn[/"Make it required\nlate SomeType propName;"\] - AlwaysSpecified-- No --> PublicAlwaysSpecifiedNotConsumed[/"Make it required\nlate SomeType propName;"\] + HasDefault== No ==> NotDefaulted + NotDefaulted((Is it set for \nevery invocation?))-- No --> End_Optional_No_Public_Api_Check + NotDefaulted-- Yes ---> PublicAPICheck + HasDefault((Does the prop have \na default value?))== Yes ==> Defaulted + Defaulted((Where is the value \ndefaulted?))--> ClassDefault + Defaulted--> LocalDefault + ClassDefault(["defaultProps getter\n(Class Component)"])--> PublicAPICheck + LocalDefault(["local var\n(Function Component)"])--> End_Optional_No_Public_Api_Check + + subgraph Public API Check + PublicAPICheck((Is the prop \npublic API?))-- Yes --> PublicAlwaysSpecified + PublicAlwaysSpecified((Is the prop mixed \nin by any other \ncomponent?))-- Yes --> End_Optional + PublicAlwaysSpecified-- No --> End_Required + PublicAPICheck-- No --> End_Required + end + + End_Optional_No_Public_Api_Check[/"Make it optional\nSomeType? propName;"\] + End_Optional[/"Make it optional\nSomeType? propName;"\] + End_Required[/"Make it required\nlate SomeType propName;"\] ``` #### Implementing abstract `Ref`s