Skip to content

Commit

Permalink
Fix links
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniGuardiola committed Jun 13, 2024
1 parent 772826d commit a40a63c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/routes/article/the-open-closed-component-part-1/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ A way I like to think about this is that you're taking a native element or compo
## When inheritance enables composition
In component-oriented UI frameworks like React and Solid.js, a recommended best practice is to [use composition instead of inheritance](<(https://legacy.reactjs.org/docs/composition-vs-inheritance.html)>).
In component-oriented UI frameworks like React and Solid.js, a recommended best practice is to [use composition instead of inheritance](https://legacy.reactjs.org/docs/composition-vs-inheritance.html).
Open/closed components seem to contradict this advice: they inherit and extend the behavior and API of a different element or component. Ironically though, building components this way enables **advanced composition patterns**.
Notably, it enables **the "render as" pattern**, which consists of rendering a component as a different element or component. Many UI component libraries support this, though the exact implementation varies.
The ([infamous](https://twitter.com/jjenzz/status/1423766700885954562)) `as` prop is probably the most known, but for the following examples, I'll use [the `render` prop from Ariakit](https://ariakit.org/composition).
The ([infamous](https://twitter.com/jjenzz/status/1423766700885954562)) `as` prop is probably the most known, but for the following examples, I'll use [the `render` prop from Ariakit](https://ariakit.org/guide/composition).
```jsx
<MyButton render={<a href="https://dio.la/" />} />
Expand Down

0 comments on commit a40a63c

Please sign in to comment.