Error when use ipfs-api in react

I want to use ipfs-api in my react project.
I successfully installed ipfs-api in my project using npm, and import ipfs and importt the module

const ipfsAPI = require('ipfs-api')
const ipfs = ipfsAPI('localhost', '5001', {protocol: 'http'})

however, when i run my project, there is an error:

 Uncaught TypeError: Object prototype may only be an Object or null: undefined
at Function.create (<anonymous>)
at Object.inherits (bundle.js:61303)
at Object.<anonymous> (bundle.js:71180)
at Object.<anonymous> (bundle.js:71186)
at __webpack_require__ (bundle.js:556)
at fn (bundle.js:87)
at Object.<anonymous> (bundle.js:71137)
at Object.<anonymous> (bundle.js:71152)
at __webpack_require__ (bundle.js:556)
at fn (bundle.js:87)

I don’t know what is wrong.

i think maybe link to webpack instead of react