I'm trying to setup a code example on tonicdev.com for my open source react component hosted on Npm.
Here's the code I'm trying to run (live edit on tonicdev.com here):
var React = require('react');
var ReactDOM = require('react-dom');
var {Calendar, CalendarControls} = require('react-yearly-calendar');
function onDatePicked(date) {
alert(date);
}
ReactDOM.render(
<Calendar
year={2016}
onPickDate={onDatePicked}
/>,
document.getElementById('calendar')
);
Tonic complains because it doesn't have a document
selector:
No document object in node. Tonic is a node environment, so document and other browser features won't exist.
But it does not provide an alternative. Since this is a React component I should render it with ReactDOM.render, which requires as second argument a domContainerNode
. How can I obtain one in Tonic?
More generally: am I doing something wrong? Is there any way to run React examples in Tonic?