-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(behaviour): adding first controlled component
- Loading branch information
1 parent
bd87440
commit ed14347
Showing
3 changed files
with
49 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import React, { memo } from 'react'; | ||
import React, { forwardRef, memo } from 'react'; | ||
import Heart from './Heart'; | ||
import Popper, { PopperProps } from './Popper'; | ||
import Popper, { PopperHandler, PopperProps, PopperRef } from './Popper'; | ||
|
||
export interface HeartsProps extends Omit<PopperProps, 'renderItem'> {} | ||
|
||
function Hearts(props: HeartsProps) { | ||
function Hearts(props: HeartsProps, ref?: PopperRef) { | ||
return ( | ||
<Popper | ||
renderItem={({ x, y, colors }, index) => ( | ||
<Heart key={index} x={x} y={y} color={colors[index]} /> | ||
)} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
} | ||
|
||
export default memo(Hearts); | ||
export default memo(forwardRef<PopperHandler, HeartsProps>(Hearts)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters