Skip to content

Instantly share code, notes, and snippets.

Avatar

Konstantin koss-lebedev

View GitHub Profile
View connected-login-form.tsx
import api from '~/common/api'
const ConnectedLoginForm = () => {
const handleSubmit = async (email, password) => {
await api.login(email, password)
}
return (
<LoginForm onSubmit={handleSubmit} />
)
View login-form-2.tsx
type Props = {
onSubmit: (email: string, password: string) => Promise<void>
}
const LoginForm = ({ onSubmit }: Props) => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const handleSubmit = async (evt) => {
evt.preventDefault()
View login-form.tsx
import api from '~/common/api'
const LoginForm = () => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const handleSubmit = async (evt) => {
evt.preventDefault()
await api.login(email, password)
}
View video-list-3.tsx
type Props = {
items: Array<Video | LiveStream>
}
const VideoList = ({ items }) => {
return (
<ul>
{items.map(item => {
if ('coverUrl' in item) {
// it's a video
View video-list-2.tsx
type Props = {
items: Array<Video | LiveStream>
}
const VideoList = ({ items }) => {
return (
<ul>
{items.map(item => {
if ('coverUrl' in item) {
// it's a video
View live-stream.tsx
type LiveStream = {
name: string
previewUrl: string
}
View video-list.tsx
type Video = {
title: string
duration: number
coverUrl: string
}
type Props = {
items: Array<Video>
}
View thumbnail-2.tsx
type Props = {
coverUrl: string
}
const Thumbnail = ({ coverUrl }: Props) => {
return <img src={coverUrl} />
}
View thumbnail.tsx
type Props = {
video: Video
}
const Thumbnail = ({ video }: Props) => {
return <img src={video.coverUrl} />
}
View chat-2.tsx
export const Chat = (messages, props) => {
// ...
return (
<ul>
{messages.map(message => {
const MessageComponent = messageFactory.render(message)
return <MessageComponent key={message.id} />
})}
</ul>