Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Publish react js library as npm package with axios dependency gives TypeError: Cannot read property 'dispose' of undefined

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Lucky Negi

User

( 8 months ago )

 

I am trying to publish a reactjs npm package with dependency as axios. My aim is to fetch data inside npm package and display it on the dom.

But it gives me the following error when using on the react project

Uncaught (in promise) TypeError: Cannot read property 'dispose' of undefined
    at Object../node_modules/react-dev-utils/webpackHotDevClient.js (webpackHotDevClient.js:45)
....
Uncaught Error: Iframe has not been created yet.
    at me (index.js:2087)
    at Object.window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady (index.js:2097)
......

My lib code is on https://github.com/e06widu/create-react-library-e06widu and published library on https://www.npmjs.com/package/create-react-library-e06widu

in the package.json I added peerDependencies as follows

"dependencies": {},
  "peerDependencies": {
    "axios": "^0.18.0",
    "react": "^16.8.1",
    "react-dom": "^16.8.1"
  },

This is how I have used it on my project

    import {
      Example,
      SecondExample,
      DashBoard,
      Greeting
    } from 'create-react-library-e06widu';

    ........

      handleLoginClick = () => {
        console.log('Handle login click');
      }

      render() {

        const greeting = "From lib e06widu"
        return (
          <div>
            <p>Login</p>
            <button className="btn btn-primary" onClick={this.handleLoginClick}>Login</button>

            <h1>My React Component</h1>
            <Greeting greeting={greeting} login={this.handleLoginClick}/>
            <Example/>
            <SecondExample/>

          </div>
        )
      }

...

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif