How can I suppress “The tag is unrecognized in this browser” warning in React?

前端 未结 4 708
梦如初夏
梦如初夏 2021-02-13 05:58

I\'m using elements with custom tag names in React and getting a wall of these errors. There\'s a GitHub issue on the subject (https://github.com/hyperfuse/react-anime/issues/3

4条回答
  •  日久生厌
    2021-02-13 06:03

    Update:

    see the answer from @triple with the correct solution: https://stackoverflow.com/a/55537927/1483006

    Orignal:

    I'm not saying this a correct thing you should really do, but you could hook console.error and filter this message by putting this somewhere before react-anime is loaded:

    const realError = console.error;
    console.error = (...x) => {
      // debugger;
      if (x[0] === 'Warning: The tag  is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.') {
        return;
      }
      realError(...x);
    };
    

    It seemed to work on the sample that was posted in the GitHub issue you linked at least. :3

提交回复
热议问题