From 7cbbedb6256a1071f2d5c1d2659a120dc8f244ae Mon Sep 17 00:00:00 2001 From: Adam Thompson Date: Thu, 23 May 2024 12:57:39 -0400 Subject: [PATCH] Update STYLEGUIDE.md --- STYLEGUIDE.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index bb5554e2d2..6b1aa69fc8 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -415,11 +415,14 @@ return
; --- -### Prefer render props over `cloneElement` +### Avoid `cloneElement` #### Why -Passing a render prop into a component instead of cloning a prop/child is more explicit, and makes it easier to trace a child component's state. +Using cloneElement is uncommon and can lead to fragile code. +Prefer render props, context, or custom Hook + +Passing a **render prop** into a component instead of cloning a prop/child is more explicit, and makes it easier to trace a child component's state. See [react.dev](https://react.dev/reference/react/cloneElement#passing-data-with-a-render-prop) for more details.