Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

always render error component #883

Closed
Maxim-Chugaev opened this issue Jul 17, 2017 · 4 comments
Closed

always render error component #883

Maxim-Chugaev opened this issue Jul 17, 2017 · 4 comments
Labels

Comments

@Maxim-Chugaev
Copy link

Maxim-Chugaev commented Jul 17, 2017

How can i render error component if field valid, but change css class on error component if field is invalid?

@davidkpiano
Copy link
Owner

The wrapper prop can be a function component that takes <Errors> props, so try this:

<Errors model="user.name"
  show={true}
  wrapper={({ fieldValue, children }) => {
    <div className={fieldValue.valid ? 'valid' : 'invalid'}>
      {children}
    </div>
  }}
/>

@Maxim-Chugaev
Copy link
Author

I'm not sure this example work for me. I want reserve place for error message and change css property 'visibility' from hidden to visible.

@davidkpiano
Copy link
Owner

I see. The logic with <Errors> is that it shows errors (of course) if and only if there are errors. Have you tried using a custom control instead?

@worc
Copy link

worc commented Feb 14, 2019

the issue is that instead of something like visibility: hidden; the element just never renders which causes that inch-worm effect in any dynamic layout, your bootstraps and css flexboxes for example, and is an extra burden when trying to debug a form.

a better approach would've been to render the Errors component, set its visibility to hidden, and remove it from the tab-navigation stack. that way the element still reserves the space it needs when it does have error messages to display, and it could be easily overridden when debugging.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants