-1

I have used the following to get the url within a function component.

const Header = () => {
  const url = typeof window !== 'undefined' ? window.location.href : '';

But I am looking to do the same for a class component so i can use Ternary.

Any idea how this can be done? I am struggling to find details outside of a functional component.

mrpbennett
  • 1,527
  • 15
  • 40

1 Answers1

0

Thanks @jonrsharpe I was overcomplicating the issue.

I have done what I need with the following:

render() {
    const url = typeof window !== 'undefined' ? window.location.href : '';

    return ( ...

Thank's for your pointers

mrpbennett
  • 1,527
  • 15
  • 40