From 7cc64bd5da416537ae08343763e41917ec386818 Mon Sep 17 00:00:00 2001 From: WillowP Date: Wed, 12 Oct 2022 11:33:23 -0400 Subject: [PATCH 1/5] Add setState example to Basic Prop Types --- docs/basic/getting-started/basic-type-examples.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/basic/getting-started/basic-type-examples.md b/docs/basic/getting-started/basic-type-examples.md index f32f5e87..d3f8314d 100644 --- a/docs/basic/getting-started/basic-type-examples.md +++ b/docs/basic/getting-started/basic-type-examples.md @@ -48,6 +48,7 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; + setState: React.Dispatch>; // the dispatch action returned by `useState` }; ``` From 0583a90d502af8306cc84ec136ff7e5387f2d358 Mon Sep 17 00:00:00 2001 From: WillowP Date: Wed, 12 Oct 2022 13:26:59 -0400 Subject: [PATCH 2/5] Improve comment for setState example Co-authored-by: swyx --- docs/basic/getting-started/basic-type-examples.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/basic/getting-started/basic-type-examples.md b/docs/basic/getting-started/basic-type-examples.md index d3f8314d..078e1a17 100644 --- a/docs/basic/getting-started/basic-type-examples.md +++ b/docs/basic/getting-started/basic-type-examples.md @@ -48,7 +48,8 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; - setState: React.Dispatch>; // the dispatch action returned by `useState` + /** if you need to pass down the dispatch action returned by `useState` in a parent component, to a child component. we gave example of a "number" here but swap out with whatever type you have in useState */ + setState: React.Dispatch>; }; ``` From bd54f4799a50e8e6f5cab21220b33a511c13fd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tammerg=C3=A5rd?= <44197016+filiptammergard@users.noreply.github.com> Date: Fri, 14 Oct 2022 12:00:42 +0200 Subject: [PATCH 3/5] Update docs/basic/getting-started/basic-type-examples.md --- docs/basic/getting-started/basic-type-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic/getting-started/basic-type-examples.md b/docs/basic/getting-started/basic-type-examples.md index 078e1a17..bd31bf66 100644 --- a/docs/basic/getting-started/basic-type-examples.md +++ b/docs/basic/getting-started/basic-type-examples.md @@ -48,7 +48,7 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; - /** if you need to pass down the dispatch action returned by `useState` in a parent component, to a child component. we gave example of a "number" here but swap out with whatever type you have in useState */ + /** when passing down the state setter function to a child component. `number` is an example, swap out with whatever the type of your state */ setState: React.Dispatch>; }; ``` From a4853f61fbcb8b077ebd72121e9b93bb8e57f7c9 Mon Sep 17 00:00:00 2001 From: WillowP Date: Fri, 14 Oct 2022 07:51:42 -0400 Subject: [PATCH 4/5] Run yarn gen-readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a26fd830..ad7f85fe 100644 --- a/README.md +++ b/README.md @@ -1126,6 +1126,8 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; + /** when passing down the state setter function to a child component. `number` is an example, swap out with whatever the type of your state */ + setState: React.Dispatch>; }; ``` From a8d5804f25910c2130222a6c80c45c18c9386ed2 Mon Sep 17 00:00:00 2001 From: WillowP Date: Fri, 14 Oct 2022 10:09:44 -0400 Subject: [PATCH 5/5] Restore reference to useState in setState comment. --- README.md | 2 +- docs/basic/getting-started/basic-type-examples.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ad7f85fe..58646d37 100644 --- a/README.md +++ b/README.md @@ -1126,7 +1126,7 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; - /** when passing down the state setter function to a child component. `number` is an example, swap out with whatever the type of your state */ + /** when passing down the state setter function returned by `useState` to a child component. `number` is an example, swap out with whatever the type of your state */ setState: React.Dispatch>; }; ``` diff --git a/docs/basic/getting-started/basic-type-examples.md b/docs/basic/getting-started/basic-type-examples.md index bd31bf66..64560b2f 100644 --- a/docs/basic/getting-started/basic-type-examples.md +++ b/docs/basic/getting-started/basic-type-examples.md @@ -48,7 +48,7 @@ type AppProps = { onClick(event: React.MouseEvent): void; /** an optional prop (VERY COMMON!) */ optional?: OptionalType; - /** when passing down the state setter function to a child component. `number` is an example, swap out with whatever the type of your state */ + /** when passing down the state setter function returned by `useState` to a child component. `number` is an example, swap out with whatever the type of your state */ setState: React.Dispatch>; }; ```