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

Hot routing and react webhooks #445

Open
1 of 3 tasks
SharePickle opened this issue Oct 1, 2020 · 0 comments
Open
1 of 3 tasks

Hot routing and react webhooks #445

SharePickle opened this issue Oct 1, 2020 · 0 comments

Comments

@SharePickle
Copy link

SharePickle commented Oct 1, 2020

Category

  • Question
  • Bug
  • Enhancement

Hello, it's probably an issue on my side, but still here's what I'm getting:
Sorry, something went wrong message is displayed when I'm navigating to any page (hot routing only) containing a custom web part which uses hooks.

Hook is used correctly, it's not after some condition.
The Web Part works if there's no hot routing navigation or you just refresh the page.

Same true for any custom web part. I could not reproduce it with OOB webparts though.

Message:
image

Source code:

export default () => {

  const theme = (window as any).__themeState__.theme;
  const colors = Object.keys(theme);
  const [key, setKey] = React.useState(+new Date());

  return (
    <div key={key}>
      <div>Theme colors <button type="button" onClick={() => setKey(+new Date())}>Refresh</button></div>
      {colors.map(c => (
        <div key={c} style={{ background: theme[c], color: 'white', padding: '4px 0', textShadow: '1px 1px black' }}>{c}: {theme[c]}</div>
      ))}
    </div >
  );

};

Expected or Desired Behavior

  • Webpart loads correctly when navigating from any other page (with hot routing).

Observed Behavior

  • Webpart loads incorrectly: Sorry, something went wrong message is displayed.

Steps to Reproduce

  • goto Home page
  • goto Pages library
  • open any page containing custom webpart with react hooks

Notes

Just noticed - it only happens when I navigate from Site Pages library or any Library (Pages, List or Documents).

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

No branches or pull requests

1 participant