recentpopularlog in

therobyouknow : event   374

« earlier  
Click Event delegation from Parent to Child in React.js & Angular.js
looking to be able to delegate, but then perhaps that is not what i want to do but rather attach event listener to each element
event  web  dev  react  reactjs  js  javascript  computing  delegate  delegation 
april 2019 by therobyouknow
reactjs - React—add a click listener to dangerouslySetInnerHTML sub-element - Stack Overflow
class Element extends React.Component {
state = {
loadTime: 0,
lastUpdate: 0
};

lastUpdateTimer = null;

componentDidMount() {
this.resetTimer();

this.lastUpdateTimer = setInterval(this.setLastUpdate, 1000);

this.dynamicContentElement.addEventListener("click", this.handleClick)
}

componentWillUnmount() {
clearInterval(this.lastUpdateTimer);
this.dynamicContentElement.removeEventListener(this.handleClick)
}

resetTimer() {
const now = Date.now();

this.setState({
loadTime: now,
lastUpdate: now
});
}

setLastUpdate = () => {
this.setState({
lastUpdate: Date.now()
});
}

getDynamicContent() {
const time = Math.round((this.state.lastUpdate - this.state.loadTime) / 1000);
return {
__html: `<p>
You are here: <strong>${time}</strong> seconods.
<br>
<button id="btn">Click to reset counter</button>
</p>`
};
}

handleClick = (e) => {
if (e.target.id === "btn") {
this.resetTimer();
}
}

render() {
return (
<div>
Dynamic content below:
<div
ref={el => this.dynamicContentElement = el}
dangerouslySetInnerHTML={this.getDynamicContent()}
/>
</div>
);
}
}
reactjs  react  js  javascript  computing  listener  click  onclick  element  subelement  sub  howto  web  dev  event  events 
april 2019 by therobyouknow
Event Bubbling
potentially useful but jsx gets in the way
react  reactjs  js  javascript  web  dev  computing  event 
april 2019 by therobyouknow
Working With Events in React | CSS-Tricks
might help event though jsx to understand things
events  react  reactjs  event  jsx  web  dev  computing  js  javascript 
april 2019 by therobyouknow
Home - 2Pears
very interesting fusion/confluence
tech  startup  entrepreneur  event 
april 2015 by therobyouknow
« earlier      
per page:    204080120160

Copy this bookmark:





to read