Skip to content

Consider adding children as a function to use instead of Slot #673

Answered by jjenzz
rafgraph asked this question in Ideas
Discussion options

You must be logged in to vote

Hi @rafgraph,

It's entirely up to you whether you use Slot or not. If you would prefer not to, this is the way we propose:

const Button = React.forwardRef((props) => <button {...props}>Tooltip trigger</button>);

<Tooltip content="Tooltip without slot">
  <TooltipTrigger as={Button} />
</Tooltip>

We're purposefully avoiding render props with our API for a few reasons:

  • We like to keep a consistent approach (not multiple ways to do the same thing) to keep API surface small, less to learn etc. and we chose Slot because;
  • We try to provide an API that requires near-zero wiring. Many of our users are relatively junior and they need something that Just Works:tm:. Unfortunately, we believe that …

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
9 replies
@rafgraph
Comment options

@benoitgrelard
Comment options

@rafgraph
Comment options

@benoitgrelard
Comment options

@jjenzz
Comment options

Answer selected by rafgraph
Comment options

You must be logged in to vote
4 replies
@benoitgrelard
Comment options

@jjenzz
Comment options

@rafgraph
Comment options

@benoitgrelard
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants