diff --git a/notes/web/react/reactBasicNotes.md b/notes/web/react/reactBasicNotes.md index 782c9e4c90..739975e0e9 100755 --- a/notes/web/react/reactBasicNotes.md +++ b/notes/web/react/reactBasicNotes.md @@ -475,6 +475,85 @@ function App() { } ``` +#### React Children API + +```jsx +import { Children, cloneElement } from 'react'; + +function Breadcrumbs({ children }) { + const arrayChildren = Children.toArray(children); + + return ( + + ); +} + +function BreadcrumbItem({ isLast, children }) { + return ( +
  • + {children} +
  • + ); +} + +export default function App() { + return ( + + Example + Hotels + A Fancy Hotel Name + + ); +} +``` + ### Refs Refs 用于返回对元素的引用.