From 8066fab26ac2ad0477af4a3a36aa1de747eea387 Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Thu, 29 Sep 2022 14:30:05 +0100 Subject: [PATCH] Last Sync: 2022-09-29 14:30:05 --- .../React/Hooks/Child_to_parent_data_flow.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Programming_Languages/Frameworks/React/Hooks/Child_to_parent_data_flow.md diff --git a/Programming_Languages/Frameworks/React/Hooks/Child_to_parent_data_flow.md b/Programming_Languages/Frameworks/React/Hooks/Child_to_parent_data_flow.md new file mode 100644 index 0000000..93a5e7a --- /dev/null +++ b/Programming_Languages/Frameworks/React/Hooks/Child_to_parent_data_flow.md @@ -0,0 +1,14 @@ +--- +title: Child to parent data-flow +categories: + - Programming Languages +tags: [javascript, react, react-hooks] +--- + +# Child to parent data flow + +Despite React having a uni-directional, downwards data-flow, it is sometimes necessary to pass events and data from a child back up to the parent. This need can arise when you want to modularize functionality within a child component rather than have everything happening in the parent, and you don't want to use a common shared higher context. + +For the example we will use the standard click incrementer. + +We have a counter on the parent that is updated in response to a click event in the child component.