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

Tokens: Move renderEntry hook calls into its own component & fix crash #1171

Merged
merged 1 commit into from
Jun 17, 2020

Conversation

Evalir
Copy link
Contributor

@Evalir Evalir commented Jun 17, 2020

Moves renderEntry hook calls and & UI depending on these into its own component, to avoid breaking the rules of hooks. Fixes #1170

Right now there's a bug that's breaking Token Manager apps with more than 10 holders (the pagination threshold) live on Mainnet; when switching to the last tab, a React error will appear, saying that a different amount of hooks were rendered, compared to the previous render. This breaks the rules of hooks, and subsequently, the app throws.

The reason this happens is actually documented on the aragonUI docs for the DataView component: the props marked with render should never hold hooks as they're called conditionally. The solution is to move the breaking parts of this function to a component.

@@ -224,4 +207,31 @@ function EntryActions({
)
}

function TokenAmount({ balance, tokenDecimals, vestings }) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the things above directly into this component; left it on the same file as it's related to the DataView only, but if preferred, we can move it.

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Nice catch! 🙏

@Evalir Evalir merged commit 911a104 into master Jun 17, 2020
@Evalir Evalir deleted the fix-hooks-token-manager branch June 17, 2020 14:34
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tokens: App crashes when switching to the last page of DataView
3 participants