javascript - get jsx compiler to ignore lines referring to other APIs -
javascript - get jsx compiler to ignore lines referring to other APIs -
i'm using react.js create components in chrome content script.
the react components should re-render when info in local storage changes.
readuserinfo : function() { chrome.storage.onchanged.addlistener(function(object changes, string areaname) { this.setstate({userinfo:changes["userinfo"].newvalue}); });
with mount function
componentdidmount: function() { this.readuserinfo(); }
of course of study jsx compiler complains chrome api calls. how can jsx compiler ignore line, i.e. leave vanilla js?
try instead:
componentdidmount: function() { chrome.storage.onchanged.addlistener(this.onchromestoragechange) }, onchromestoragechange: function(changes, areaname) { this.setstate({ userinfo:changes["userinfo"].newvalue }) }
i used react’s autobinding , removed invalid argument look had (probably copy/pasted docs). don’t forget remove listener when component unmounts.
javascript google-chrome-extension reactjs content-script react-jsx
Comments
Post a Comment