Где здесь ошибка?
index.js
src\components\itemsList.js
Line 4:34: 'Context' is not defined no-undef
Search for the keywords to learn more about each error.
import React,{createContext} from 'react';
import ReactDOM from 'react-dom/client';
import ItemsList from "./components/itemsList";
const Context = createContext(null)
const arrayse=[
{'id':1,'description':'description1'},
{'id':1,'description':'description1'},
{'id':1,'description':'description1'},
{'id':1,'description':'description1'},
{'id':1,'description':'description1'},
];
//
function App() {
return (
<Shop/>
)
}
//
function Shop() {
return (
<ItemsList/>
);
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Context.Provider value={{arrayse:arrayse}}>
<App />
</Context.Provider>
);
itemsList.js
import React, {useContext} from 'react';
import Item from './item.js';
function ItemsList() {
const {arrayse} = useContext(Context)
return (
arrayse.map(array=><Item arrayse={array}/>)
);
}
export default ItemsList;
item.js
import React from 'react';
function Item ({arrayse}) {
return (
<div>
<h1>id:{arrayse.id}</h1>
<p>desc: {arrayse.description}</p>
</div>
);
}