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
type Props = HTMLAttributes<HTMLInputElement> | |
const CustomInput = ({ onChange, ...props }: Props) => { | |
const handleChange = (event) => { | |
/// ... some logic | |
onChange(event) | |
} | |
return <input {...props} onChange={handleChange} /> | |
} |
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
type Props = HTMLAttributes<HTMLInputElement> & { | |
onUpdate: (value: string) => void | |
} | |
const CustomInput = ({ onUpdate, ...props }: Props) => { | |
const onChange = (event) => { | |
/// ... some logic | |
onUpdate(event.target.value) | |
} |
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
type Props = InputHTMLAttributes<HTMLInputElement> | |
const CustomInput = (props: Props) => { | |
// ...some additional logic | |
return <input {...props} /> | |
} |
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
type Props = { value: string; onChange: () => void } | |
const CustomInput = ({ value, onChange }: Props) => { | |
// ...some additional logic | |
return <input value={value} onChange={onChange} /> | |
} |
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
type Props = InputHTMLAttributes<HTMLInputElement> | |
const Input = (props: Props) => { /* ... */ } | |
const CharCountInput = (props: Props) => { | |
return ( | |
<div> | |
<Input {...props} /> | |
<span>Char count: {props.value.length}</span> | |
</div> |
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
import styled from 'styled-components' | |
const Button = (props) => { /* ... */ } | |
const StyledButton = styled(Button)` | |
border: 1px solid black; | |
border-radius: 5px; | |
` | |
const App = () => { |
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
const TextMessage = ({ text }) => { | |
return ( | |
<div> | |
<p>{text}</p> | |
</div> | |
) | |
} | |
const ImageMessage = ({ text, imageUrl }) => { | |
return ( |
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
const Message = ({ text, imageUrl, audioUrl }) => { | |
if (audioUrl) { | |
return ( | |
<div> | |
<audio controls> | |
<source src={audioUrl} /> | |
</audio> | |
</div> | |
) | |
} |
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
const Message = ({ text, imageUrl }) => { | |
return ( | |
<div> | |
{imageUrl && <img src={imageUrl} />} | |
{text && <p>{text}</p>} | |
</div> | |
) | |
} |
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
const Message = ({ text }) => { | |
return ( | |
<div> | |
<p>{text}</p> | |
</div> | |
) | |
} |
NewerOlder