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

Render child of MainLayout when state is changed #11

Merged

Conversation

joaquin-alfaro
Copy link
Contributor

First of all, thanks a lot for the template!

Child of MainLayout not re-rendered

The root component of the child of MainLayout is not re-rendered after changing the state.
It affects just to the root component, the tree is re-rendered upon the state changes.

This behaviour is confusing when using hooks on nextjs pages because changes are not reflected in the page but in the children components.

How to reproduce

  1. Create a nextjs page as below
const Home: NextPage = () => {
  const { address } = useAccount()
  return (
    <MainLayout>
      <HeaderMenu>
        <HeaderMenuButtons enabled={['auth']} />
      </HeaderMenu>
      <h1>### {address} ###</h1>
      <GetUserDataDemo />
   <MainLayout>
)
  1. Connect your Elrond account
  2. The value of address inside <h1> is not updated but the same value in component GetUserDataDemo is updated

@juliancwirko
Copy link
Member

juliancwirko commented Aug 8, 2022

Thanks, I will test it as soon as possible. I need to check all possible implications.
There is probably too much 'optimization' there in the MainLayout.

@joaquin-alfaro
Copy link
Contributor Author

Thanks @juliancwirko
Even it works, I am not sure of the implications of using the children parameter. I will check it more.

@juliancwirko juliancwirko merged commit 9c02ef3 into xdevguild:main Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants