Sorry, React doesn't do anything special with canvas -- it simply defers to the browser for all the drawing stuff.
You might want to use something like https://github.com/learnboost/node-canvas instead for server rendering of canvas code.
Question
I'm trying to mock the canvas in Node.js using the virtual DOM in the React.js framework but I'm having trouble finding out how to create a canvas element and access the canvasContext.
I want to be able to create a new canvas object, get the context and draw a few lines.
This is what I've figured out so far (after npm install react)
>var DOM = require('react').DOM;
undefined
>var canvas = DOM.canvas();
undefined
>canvas
{ props: { __owner__: null },
_lifeCycleState: 'UNMOUNTED',
_pendingProps: null,
_pendingCallbacks: null }
Is there somewhere else that I should be creating the canvas and how can I access the canvas context?
Thanks!
Solution
Sorry, React doesn't do anything special with canvas -- it simply defers to the browser for all the drawing stuff.
You might want to use something like https://github.com/learnboost/node-canvas instead for server rendering of canvas code.