I'm still beginner in ReactJS and JavaScript and I'm having trouble using this.
I'm rendering a list of properties and when I do onMouseOver I'd like to get the element I'm hovering over with this. But it's returning undefined.
Can you tell me why I'm getting this error?
Here's my code I put into codesandbox.io
Thank you very much in advance.
import React from "react";
import "./styles.css";
import Property from "./components/Property";
import { mock } from "./data/mock";
export default function App() {
const [data] = React.useState(mock.data.dora.exploreV3.sections[2].items);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
{data.map((item) => (
<Property key={item.listing.id} item={item} />
))}
</div>
);
}
import React from "react";
const Property = ({ item }) => {
return (
<div
style={{
padding: "5px 0",
cursor: "pointer"
}}
onMouseOver={() => console.log("item: ", this)}
>
{item.listing.name}
</div>
);
};
export default Property;
