Skip to content

Commit

Permalink
Update STYLEGUIDE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSonOfThomp committed May 23, 2024
1 parent 84d1299 commit 7cbbedb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,14 @@ return <div></div>;

---

### 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.

Expand Down

0 comments on commit 7cbbedb

Please sign in to comment.