swordev / suid

A port of Material-UI (MUI) built with SolidJS.
https://suid.io
MIT License
673 stars 48 forks source link

How to use directives with SUID components? #237

Closed Bersaelor closed 1 year ago

Bersaelor commented 1 year ago

So the solidjs form validation example uses directives.

When I put a console.log into the validate function it gets printed for:

<input
  name="email"
  type="email"
  placeholder="Email"
  required
  use:validate={[emailInValid]}
/>

when I however put the use:validate on a <TextField> nothing happens:

<TextField
  name="email"
  type="email"
  placeholder="Email"
  component='input'
  required
  use:validate={[emailInValid]}
/>

Is there a trick on how to use directives with suid?

juanrgm commented 1 year ago

SolidJS directives

Important: use: is detected by the compiler to be transformed, and the function is required to be in scope, so it cannot be part of spreads or applied to a component.