score:2
Accepted answer
refs can be null on rerenders therefore always null check before accesssing properties of elements refs. here is what gaearon has to say about refs.
const handlescroll = () => {
if(!ref.current) return
if (ref.current.getboundingclientrect().y <= -580 || null) {
console.log(ref.current.getboundingclientrect().y);
setsticky(true);
} else {
setsticky(false);
}
};
score:0
sorry for writing late.
if(status: solved)
{
**congratulations**
}
else{
well, i guess the problem is not in your js file, maybe it is in your .html file. go there and either use defer where u linked your js file or put it under your targeted element.
that might work, at least it did for me!
}
Source: stackoverflow.com
Related Query
- TypeError Cannot read property 'country_code' of null
- Cannot read property 'getHostNode' of null
- Uncaught TypeError: Cannot read property 'props' of null
- TypeError when using React: Cannot read property 'firstChild' of undefined
- Cannot read property 'refs' of null react error react js
- Uncaught TypeError: Cannot read property 'state' of null in react
- Cannot read property 'style' of null - Google Sign-In Button
- cannot read property of null doing destructing
- React component returning cannot read property '__reactInternalInstance$ of null after trying to access array
- Error: Cannot read property 'UIAppFonts' of null
- Cannot read property '_currentElement' of null
- ReactNative - Tapping row in ListView gives error: Cannot read property `_pressRow` of null
- React - Cannot read property 'setState' of null
- Cannot read property 'selectionEnd' of null using React + Jest + Datepicker + TextMask
- Jest test Cannot read property 'Object.<anonymous>' of null
- TypeError: Cannot read property 'name' of null
- TypeError: Cannot read property 'map' of null
- How to get over Cannot read property 'removeEventListener' of null in react
- TypeError: Cannot read property 'createEvent' of null React Apollo testing
- React tutorial: Uncaught TypeError: Cannot read property 'data' of null
- Cannot read property 'getBoundingClientRect' of null
- React: Uncaught TypeError: Cannot read property '_currentElement' of null
- TypeError: Cannot read property 'value' of null in React Form
- Reactjs this.state giving Uncaught TypeError: Cannot read property 'groupsData' of null
- Uncaught TypeError: Cannot read property 'setState' of null
- Cannot read property 'state' of null
- React refs: Cannot read property 'focus' of null
- TypeError: Cannot read property 'getState' of null
- TypeError: Cannot read property 'focus' of null
- TypeError: Cannot read property 'dispatch' of null
More Query from same tag
- How to detect if draggable item is droppable at current location in react-dnd
- Getting Rocketchat History in React
- Toggleing a Component in React
- map is not a function returning div inside ternary operator
- React - Styled Component change with Click
- react-fontawesome importing all icons
- Is it possible to get a React property outside of React?
- How to prioratize onPaste over onKeyPress in Safari
- Redux-Saga call() and put() in map
- Antd file upload appending file after returning false from beforeUpload
- React & HTML: Highlight a table cell with booleans
- Testing a composed Reactjs component with Enzyme
- Why is my wrapper disrupting the CSS of the content it is wrapping?
- Prepend String before Moment Timestamp
- React event.target is undefined for only one input element
- Hot reload is duplicating websockets
- Why I receive this error using componentWillReceiveProps?
- React useEffect in function
- Using React forwardRef with Redux connect
- animate component entering the DOM in ReactJS
- Strange behavior/loading patterns when using React + Meteor pre-filling forms
- Using Refs To Style A Div Element
- Add color on every button Click React js
- How to call the parent method from child in react componentDidMount
- How to integrate javascript libraries into react?
- React: create dismissable Alert component
- Using font awesome styles in react
- How to solve webpack 2 error ,module build failed:SyntaxError,,?
- React/TypeScript: Union Types in state of Context API
- React add child table in datatable