Props7 / 12
Up next

Function props

interface ButtonProps {
  label: string;
  onPress: () => void;
}

// the parent decides what the click does
function Button({ label, onPress }: ButtonProps) {
  return <button onClick={onPress}>{label}</button>;
}

export default Button;
What you're solving

pass a callback down as a prop