Fetching a DOM node from a React component is quite simple from the part itself, but what if you want to work backwards: do you restore a instance of a component by a DOM node? This is a task that allows the Dijit framework of the old Dojo Toolkit with the
dojo.byId method, so it made me think whether you could do the same with React. It turns out that you can retrieve a component instance at DOM node!
The following function allows you to obtain an instance of a React component on a DOM node:
function findReactElement (node)
If the node is a component file of React, you will see a lot of amazing information, such as the props, state, context, refs, list of methods and more:
Modifying props / state and calling display methods do not seem to do anything, so manipulation does not seem possible from the outside, but it is useful to get the component instance based on the DOM node if there is nothing other than inspection. Nice!
Page visibility API
One event that has always been missing within the document is a signal for when the user looks at a particular tab or to another tab. When does the user switch off our site to look at something else? When will they return?
attachEvent. Times have changed, but there are still a few functions that every developer should …
CSS Fixed placement
If you want to keep an element at the same location in the viewport, regardless of where on the page the user is located, the function for fixed positioning of CSS what you need.
Above we set our element 2% of both the top and the right side of the …