I encountered an issue when trying to compile a code in Reactjs. As a beginner in Reactjs, I'm struggling with this.
Module not found: Error: Package path ./cjs/react.development is not exported from package /Users/mansi/letsgrowmore/to-do-list/my-react-app/node_modules/react (see exports field in /Users/mansi/letsgrowmore/to-do-list/my-react-app/node_modules/react/package.json)
ERROR in ./src/Components/Todolist.js 7:0-51
Module not found: Error: Package path ./cjs/react.development is not exported from package /Users/mansi/letsgrowmore/to-do-list/my-react-app/node_modules/react (see exports field in /Users/mansi/letsgrowmore/to-do-list/my-react-app/node_modules/react/package.json)
webpack compiled with 1 error
import React from 'react';
import useState from 'react/cjs/react.development';
import Todoform from './Todoform';
export default function TodoList() {
const [todos, setTodos] = useState([]);
const addTask = task => {
if (!task.text) {
return;
}
const newTodos = [task, ...todos];
setTodos(newTodos);
}
return (
<div>
<Todoform addTask={addTask}></Todoform>
</div>
);
}
I attempted npm update and even tried downgrading the version but the error persisted.