Skip to content
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

Refs #33078 - Move forceRender inside hook #9635

Merged
merged 1 commit into from
Sep 14, 2021

Conversation

jeremylenz
Copy link
Member

I used JavaScript Sets in TracesTab.js to keep track of which table rows are selected. The biggest disadvantage of this was that you would have to call a forceRender() function each time you mutate the set, or else React wouldn't know when to update the DOM. This PR automates that and removes the need to call forceRender() yourself.

Usage before:

const [mySet, forceRender] = useSet([]);
...
mySet.add(3);
forceRender();

Usage after:

const mySet = useSet([]);
...
mySet.add(3); // forceRender is called for you

@theforeman-bot
Copy link

Issues: #33078

Copy link
Contributor

@Andrewgdewar Andrewgdewar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack!
Although I do wish there were a way to do this that was simplified.
The more code in the system that is doing a thing that does a thing that does a thing, the more difficult it is to maintain and fix when bugs come along.

@jeremylenz jeremylenz merged commit 5a75550 into Katello:master Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants