question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper way to show/hide components?

See original GitHub issue

I’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:open
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
marcus-at-localhostcommented, May 7, 2020

I’m not a 100% sure, but could it be that you need to trigger a redraw? There must be a redraw() function or triggerRedraw() somewhere on some object…

0reactions
randallknutsoncommented, Jun 5, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found