Redirected page breaks

Hi there,

I have a page that has a 301 redirection.

The Root template for the pages look like this

const Root = ({ state, actions, libraries }) => {
  const data = state.source.get(state.router.link);
  const post = data.isReady && !data.isError && !data.isCategory ? state.source[data.type][data.id] : null;
}

But the page breaks at const post as I get the usual Cannot read properties of undefined (reading 'undefined') message. If I comment post out, the page redirects fine.

Do you have any idea why that is happening?

Thanks

In case anyone needs this, I think the solution here is to add a !data.isRedirection to the const post assignation check.