DEV Community

loading...

× TypeError: react__WEBPACK_IMPORTED_MODULE_0___default is not a function or its return value is not iterable

Supermonk
・1 min read

import React from 'react'
//import useState from 'react-dom';
import useState from 'react';

export const Tindercards = () => {
const [people, setPeople] = useState([
{
name: "Elon Musk",
url: "https://www.biography.com/.image/ar_1:1%2Cc_fill%2Ccs_srgb%2Cfl_progressive%2Cq_auto:good%2Cw_1200/MTc5OTk2ODUyMTMxNzM0ODcy/gettyimages-1229892983-square.jpg"
}
]);

return (
    <>
        <div className="tindercards">

        </div>
    </>
)
Enter fullscreen mode Exit fullscreen mode

}

export default Tindercards;

Discussion (1)

Collapse
nilomiranda profile image
Danilo Miranda

useState is not a default export from 'react'.

Try changing your imports from this:

import React from 'react'
//import useState from 'react-dom';
import useState from 'react';
Enter fullscreen mode Exit fullscreen mode

to this:

import React, { useState }  from 'react'
Enter fullscreen mode Exit fullscreen mode

Or you can simply use

React.useState()
Enter fullscreen mode Exit fullscreen mode

without needing to import useState