Props trong React là gì?
Props trong React là gì?
Props (properties) là dữ liệu truyền từ component cha xuống con, chỉ đọc (immutable) — cách component tuỳ biến hành vi/ hiển thị.
type Props = { name: string; onPress?: () => void };
function Greeting({ name, onPress }: Props) {
return <Text onPress={onPress}>Xin chào {name}</Text>;
}
<Greeting name="An" onPress={() => console.log("tap")} />
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.