-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getContext Error question (not an issue, not a new feature) #121
Comments
@jycouet you should be able to use the // MyField.svelte
<script>
import {key} from 'svelte-forms-lib';
const {errors} = getContext(key);
</script> Have a look at Alternatively, since We need documentation to cover this, however, as it's likely not obvious that context is retrievable. I'll close this issue for now, but feel free to open if you're experiencing issues. EDIT: added retrieving errors to example |
I played a lot yesterday with the getContext, but didn't manage to get the info. Thx a lot @larrybotha & good that the example will shows this too, awesome 🎉 |
I have been trying to obtain the form context using the key as described above. But I get an error |
@annazus you'll need to manually pass the return value of <Form context={createFormResult}>
//...
</Form> What's likely happening here is because you're instantiating the form outside of the See #101 and https://github.com/tjinauyeung/svelte-forms-lib/blob/master/lib/components/Form.svelte#L14 Documentation is lacking on this |
Thx a lot for the lib, it's very powerful!
To be able to use and reuse my own styles in my application, I wrapped
<Field>
in<MyField>
So I have:
In
<MyField>
, I have<ErrorMessage {name} ... />
, and I can see well the error.But how can I retreive
$errors
in script in<MyField>
component?=> To be able to style my components depending on errors.
Thx for the info
The text was updated successfully, but these errors were encountered: