Drawing on canvas or Refs and the DOM
See original GitHub issueI’ve found very cool examples here using SVG animation. However not found any canvas ~animation~ drawing examples.
I’m trying to develop hyperapp PieCountdown component as this one.
In React I would use Refs to get access to canvas DOM element.
class Countdown extends Component {
componentDidMount() {
const ctx = this.canvas.getContext('2d');
// draw something to canvas
// ...
}
render() {
return (
<canvas ref={(canvas) => { this.canvas = canvas; }} />
);
}
};
export default Countdown;
Is it possible to get access to raw DOM elements in hyperapp, or what is recommended way to do canvas ~animations~ drawing?
Issue Analytics
- State:
- Created 6 years ago
- Comments:48 (33 by maintainers)
Top Results From Across the Web
Using React With Canvas Element - Anton Lavrenov Blog
It allows you to draw DOM-like objects (images, texts) on canvas element in very performant way. It is NOT about drawing graphics, but...
Read more >Using React Hooks with canvas - Koen van Gilst
For that we have to use a ref , which is a reference to the actual canvas DOM element. Now that we have...
Read more >Canvas with React.js - Medium
We need a canvas element to draw inside it, so we must create a component ... The React way to get a dom...
Read more >Build a Drawing App with React - YouTube
Build a Drawing App with ReactIn this video I show you how to build ... Add code for drawing on canvas 22:20 Draw...
Read more >Bindings/Refs - SolidJS · Reactive Javascript Library
You can always get a reference to a DOM element in Solid through assignment, since JSX creates actual ... <canvas ref={canvas} width="256" height="256"...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mauron85 Yup that’s right. I called it “top-node” specifically to avoid confusion with root (which is an element – not a virtual dom node, btw). But yeah. The first, topmost
h(...
call or<div..
inside yourview: (state, actions) => ...
is the thing that can’t be keyed nor have onremove bound to it.I agree that’s kind of unexpected. I mean I get why it is, but I had never thought of it until your examples.
Recent commit, before 0.10.0 I think. This was an undocumented thing, so can’t complain. 😉😏