schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

TypeError: Object(...) is not a function #77

Closed grounded-warrior closed 6 years ago

grounded-warrior commented 6 years ago

Getting TypeError: Object(...) is not a function when trying to implement this per the demo. Simply adding

import { Provider } from "react-alert";
import AlertTemplate from "react-alert-template-basic";

to the top of my file causes the error

schiehll commented 6 years ago

Hey @grounded-warrior, sorry but you will have to give me more details.

Can you reproduce the error using this template here?

schiehll commented 6 years ago

Closing due to inactivity

Santiago8888 commented 5 years ago

I could not reproduce it.

Here is the complete log of the issue:

Uncaught TypeError: Object(...) is not a function at Provider (react-alert.js:303) at mountIndeterminateComponent (react-dom.development.js:15425) at beginWork (react-dom.development.js:15956) at performUnitOfWork (react-dom.development.js:19102) at workLoop (react-dom.development.js:19143) at HTMLUnknownElement.callCallback (react-dom.development.js:147) at Object.invokeGuardedCallbackDev (react-dom.development.js:196) at invokeGuardedCallback (react-dom.development.js:250) at replayUnitOfWork (react-dom.development.js:18350) at renderRoot (react-dom.development.js:19261) at performWorkOnRoot (react-dom.development.js:20165) at performWork (react-dom.development.js:20075) at performSyncWork (react-dom.development.js:20049) at requestWork (react-dom.development.js:19904) at scheduleWork (react-dom.development.js:19711) at scheduleRootUpdate (react-dom.development.js:20415) at updateContainerAtExpirationTime (react-dom.development.js:20441) at updateContainer (react-dom.development.js:20509) at ReactRoot.push../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render (react-dom.development.js:20820) at react-dom.development.js:20974 at unbatchedUpdates (react-dom.development.js:20292) at legacyRenderSubtreeIntoContainer (react-dom.development.js:20970) at render (react-dom.development.js:21037) at Module../src/index.js (index.js:21) at webpack_require (bootstrap:782) at fn (bootstrap:150) at Object.0 (tarotCard.js:148) at webpack_require (bootstrap:782) at checkDeferredModules (bootstrap:45) at Array.webpackJsonpCallback [as push] (bootstrap:32) at main.chunk.js:1

abecks commented 5 years ago

I am also getting this error trying to use the basic template:

react-hot-loader.development.js:285 TypeError: Object(...) is not a function
    at Provider (react-alert.js:309)
    at ProxyFacade (react-hot-loader.development.js:791)
    at mountIndeterminateComponent (react-dom.development.js:14811)
    at beginWork (react-dom.development.js:15316)
    at performUnitOfWork (react-dom.development.js:18150)
    at workLoop (react-dom.development.js:18190)
    at renderRoot (react-dom.development.js:18276)
    at performWorkOnRoot (react-dom.development.js:19165)
    at performWork (react-dom.development.js:19077)
    at performSyncWork (react-dom.development.js:19051)

Line 309. Little obfuscated because of webpack.

  var root = Object(react__WEBPACK_IMPORTED_MODULE_0__["useRef"])(null);

My code:

import { transitions, positions, Provider as AlertProvider } from 'react-alert'
import AlertTemplate from 'react-alert-template-basic'

const alertOptions = {
  // you can also just use 'bottom center'
  position: positions.TOP_RIGHT,
  timeout: 5000,
  offset: '30px',
  // you can also just use 'scale'
  transition: transitions.SCALE,
}

const App = props => (
  <AlertProvider template={AlertTemplate} {...alertOptions}>
     // ...
  </AlertProvider>
)
abecks commented 5 years ago

My React was out of date, upgrading has resolved it.