preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
949 stars 148 forks source link

TypeError: Cannot call a class as a function when using with React Component #467

Closed rafaelklaessen closed 6 years ago

rafaelklaessen commented 6 years ago

Hi! I'm trying to use react-tradingview-widget with a Preact project and I'm getting the following error: screen shot 2018-03-03 at 15 15 41

I'm not experienced with Preact or Preact Compat so I've got no idea what causes this error. Other React components seem to work fine.

The Preact project was created with preact create material [name] and I'm using the following code to render the component:

<TradingViewWidget symbol="NASDAQ:AAPL" />
developit commented 6 years ago

@rafaelklaessen don't use an arrow function for your render method. It's wasteful (a new function is created for every instance of the class), and Preact might end up thinking your classful component is a function.