score:13
use refs.
first, hook-up a ref
attribute on each of your jsx cols element. then, use this ref
, inside the componentdidmount
method, to access the component's dom node (the actual htmlelement). finally, get element's position / offset or anything else that you need.
const col = react.createclass({
componentdidmount: function() {
// this.refs.col1 is the actual dom element,
// so you can access it's position / offset or whatever
const offsettop = this.refs.col1.offsettop;
},
render() {
return (
<div classname="col" ref="col1">
</div>
);
}
});
ps: i am not sure what do you mean by saying element y
position. anyways, once you know how to get the dom element (this.refs.col1
), you can then use javascript to retrieve the position you need.
Source: stackoverflow.com
Related Query
- How to get the ReactJS element inside componentDidMount()?
- How to get the ref of a child component inside parent component in ReactJS
- how to get the id of element inside render and pass it to a function
- How to add an element in the your index inside a array? ReactJs
- How to get the new child element reactjs
- how can I retrieve the updated state element in componentDidMount in reactjs
- How to get DOM element id with OnClick inside map fuction in ReactJs
- How to get the event target inside the parent component in ReactJS
- how to get the clicked element when clicked in ReactJS when using map?
- How to get something from the state / store inside a redux-saga function?
- How to get the width of a react element
- How can I get the URL address from the browser in ReactJS (servers URL)
- How to get the react component instance corresponding to event.target element in a click handler?
- How do I get the id of a button that was clicked? ReactJS
- how to get element by component name in ReactJS
- How to get as e.target the exact element at which onClick is specified?
- How can I get the element of another component in React.js?
- How to get the element with the testid using react testing library?
- How to get the ref of the first element that's rendered with .map?
- How to get bootstrap card to stay in the middle of the screen in reactjs
- ReactJs - How to get updated state while inside a thunk promise
- How to display an element from a true or false inside Object? Javascript ReactJs
- How to get value from useState inside the function
- How do I get the dom node of a child element in a component without adding logic to its parent/children?
- How to access URL parameter inside the ComponentDidMount method in react correctly
- How to get the length of the text inside the React component
- How to get the Id of an element from <select> in React?
- How to get an element By ID inside React.Fragment?
- How to get date from Date Picker and show in the table? Material-UI. ReactJS
- How to map inside map function and show the data in Reactjs
More Query from same tag
- how to prevent react-router-dom nested routes to get confused with route params
- Nodejs - React download file from s3 bucket using pre-signed url
- If and why the CSS should be put outside the react function components(near the imports)?
- How to render images dynamically to React Carousel?
- How to map dictionary in react class component
- React + Redux : Testing redux hooks
- How send simple value from axios.post to asp.net core?
- How to write a multi export in react?
- react bootstrap table button conflict with row clicking
- Vercel Deployment Error: Command "npm run build" exited with 1
- Js substring doesn't work on react fetched string
- How Do I Style A React Material-UI Required TextField
- How to make the first item of the list always be at the top and the rest of the list will scroll independently of it
- Connected property is updated only once, its not updating for second time
- KeyCloak React refreshToken expired token
- change facebook like button language without reloading page
- How do I create a download file link in React?
- Using Ramda `range` to duplicate, but need to interject at every 3rd (React)
- Mocking single function from a module which also calls it from another function, jest, typescript
- Unable to route via Navbar in React application
- Why are my mdx files not showing simple markdown syntax like lists and headings? (Next.js, mdx-bundler)
- ReactJS Component not displaying
- How to set a global font family in react js?
- Warning: Functions are not valid as a React child, using a conditional rendering
- react-bootstrap Add Options to Select - ReactJS
- Multiple Instances of React Application on the Same Page
- External Vendor Scripts( JS, Jquery) Not working after render in ReactJS
- Invalid hook call. ReacJs
- Error in MuiThemeProvider
- Formik ErrorMessage not appearing on browser