1

I am trying to use React.createRef
Current code works in Chrome, Firefox, Safari, Edge but in IE this.calendarRef.curent is null

    constructor(props) {
      super(props);
      element = this;
      this.state= {
         allDayText: 'All day',
         direction: '',
         view: this.props.with,
         date: new Date().toISOString().split('T')[0]
      };
       this.cubeRef = React.createRef();
    }

    componentDidMount(){
       console.log(this.cubeRef);
    }


    <CubeContainer
        ref={this.cubeRef}
    />
Takhtak Team
  • 131
  • 1
  • 2
  • 10
  • Where is `this.calendarRef.curent` in your code? – Shlang Apr 19 '20 at 09:57
  • @Shlang sorry. `this.cubeRef.current` is `null` in `componentDidMount` – Takhtak Team Apr 19 '20 at 18:26
  • `element` is undefined in your code snippet. I made a [code sample](https://stackblitz.com/edit/react-acnshd?file=index.js) and `this.cubeRef` won't be null in IE. I can't reproduce the issue with your above code. You could check the result: https://i.stack.imgur.com/XHKV2.png. If the issue still persists, could you please provide [a minimal, reproducible sample](https://stackoverflow.com/help/minimal-reproducible-example)? You could use some online code editor like stackblitz. – Yu Zhou Apr 20 '20 at 08:07
  • I can't open your snippet in `IE`. The error codes are `SCRIPT1002` and `SCRIPT5009`. – Takhtak Team Apr 20 '20 at 10:57
  • Yes, I can't find an online React code editor which can be opened in IE. You could check the code sample in other browsers and run the same code locally in IE. I also run the same code locally and get the result. – Yu Zhou Apr 21 '20 at 07:53

0 Answers0