Getting “TypeError: document.getElementById(…) is null” when using react.js with chart.js
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using react and chart.js together to plot bar chart. But in chart.js we have to use canvas tags and to find that tag and to place bar chart in it we use our normal document.getElementById() method. I tried lots of combinations like putting document.getElementById() at the beginning, or inside a $(document).ready() , even within react's componentDidMount() method. But Still I am getting " TypeError: document.getElementById(...) is null ". If anyone know about it, please give me a suggestion. Thank You. Here is the code which I am trying