Proper way to show/hide components?
See original GitHub issueI’ve searched the docs fairly extensively but haven’t found anything on this. Is there a “Right Way” to programmatically hide and show components?
I’ve tried using:
let myComponent = form.getComponent('componentName');
// To hide:
myComponent.component.hidden = true;
// And to show:
myComponent.component.hidden = false;
While this works for hiding a component, I’m having some trouble with showing it later on. Sadly a jsfiddle reproduction doesn’t work; it shows there just fine, so there must be something about my scenario that’s more complicated.
Is there another, or better, way of hiding and showing a component?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
How to Show and Hide ReactJS Components | Pluralsight
To show or hide any component using any condition, we should have the values, and based on those values, we can hide or...
Read more >Show or hide element in React - Stack Overflow
Class hiding is probably the easiest to implement. As mentioned you just create a CSS class with display: none and assign the class...
Read more >How to show and hide components and elements in React
To show and hide components and elements in React you will need to either use conditional rendering, css styles or animation libraries. For...
Read more >How to Show and Hide Elements in React - Telerik
At this point we have a few options to focus on — the first being directly modifying the HTML element's style property, setting...
Read more >How to Hide or Show Components in SOLIDWORKS ...
Tab to Hide, Shift+Tab to Show. The last method we'll cover is one of my favorites. As you're moving our cursor over components,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not a 100% sure, but could it be that you need to trigger a redraw? There must be a
redraw()
function ortriggerRedraw()
somewhere on some object…I don’t have a good example of this and tried to do it yesterday. Looks like in the ngFormio library we are just manually calling formLoad. https://github.com/formio/ngFormio/blob/master/src/directives/formio.js#L56-L61
You can probably do something like this where you just set the form again after the promise resolves.