function App() {
const [resource, setResource] = useState(initialResource);
const [isPending, startTransition] = useTransition();
// ...
//app.js
import React, { useRef, useState } from "react";
import styled from "styled-components";
import "./styles.css";
function App() {
const [loc, setLoc] = useState([0, 0]);
const onMouseOver = (e) => {
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY]);
};
return (
<div className="wrapper">
<Container className="wrap" onMouseMove={onMouseOver}>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`;
const Hover = styled.div`
position: absolute;
top: ${(props) => props.y + 30}px;
left: ${(props)
import React, {useRef, useState, useTransition} from 'react'
import './App.css';
import styled from 'styled-components'
function App() {
const [loc, setLoc] = useState([0,0])
const [isPending, startTransition] = useTransition();
const onMouseOver = (e) => {
startTransition(()=>{
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY])
})
}
return (
<div className='wrapper'>
<Container
className='wrap'
onMouseMove={onMouseOver}
>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`
const Hover = styled.div`
position:absolute;
top:${props => props.y+30}px;
left:${props => props.x+30}px;
width:100px;
height:50px;
background-color: white;
`
export default App;
function App() {
const [resource, setResource] = useState(initialResource);
const [isPending, startTransition] = useTransition();
// ...
//app.js
import React, { useRef, useState } from "react";
import styled from "styled-components";
import "./styles.css";
function App() {
const [loc, setLoc] = useState([0, 0]);
const onMouseOver = (e) => {
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY]);
};
return (
<div className="wrapper">
<Container className="wrap" onMouseMove={onMouseOver}>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`;
const Hover = styled.div`
position: absolute;
top: ${(props) => props.y + 30}px;
left: ${(props)
import React, {useRef, useState, useTransition} from 'react'
import './App.css';
import styled from 'styled-components'
function App() {
const [loc, setLoc] = useState([0,0])
const [isPending, startTransition] = useTransition();
const onMouseOver = (e) => {
startTransition(()=>{
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY])
})
}
return (
<div className='wrapper'>
<Container
className='wrap'
onMouseMove={onMouseOver}
>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`
const Hover = styled.div`
position:absolute;
top:${props => props.y+30}px;
left:${props => props.x+30}px;
width:100px;
height:50px;
background-color: white;
`
export default App;
function App() {
const [resource, setResource] = useState(initialResource);
const [isPending, startTransition] = useTransition();
// ...
//app.js
import React, { useRef, useState } from "react";
import styled from "styled-components";
import "./styles.css";
function App() {
const [loc, setLoc] = useState([0, 0]);
const onMouseOver = (e) => {
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY]);
};
return (
<div className="wrapper">
<Container className="wrap" onMouseMove={onMouseOver}>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`;
const Hover = styled.div`
position: absolute;
top: ${(props) => props.y + 30}px;
left: ${(props)
import React, {useRef, useState, useTransition} from 'react'
import './App.css';
import styled from 'styled-components'
function App() {
const [loc, setLoc] = useState([0,0])
const [isPending, startTransition] = useTransition();
const onMouseOver = (e) => {
startTransition(()=>{
setLoc([e.nativeEvent.offsetX, e.nativeEvent.offsetY])
})
}
return (
<div className='wrapper'>
<Container
className='wrap'
onMouseMove={onMouseOver}
>
<Hover x={loc[0]} y={loc[1]}>
x:{loc[0]} y:{loc[1]}
</Hover>
</Container>
</div>
);
}
const Container = styled.div`
position: relative;
`
const Hover = styled.div`
position:absolute;
top:${props => props.y+30}px;
left:${props => props.x+30}px;
width:100px;
height:50px;
background-color: white;
`
export default App;