forked from gitalk/gitalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (25 loc) · 796 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from 'react'
import { render } from 'react-dom'
import 'es6-promise/auto'
import GitalkComponent from './gitalk'
class Gitalk {
constructor (options = {}) {
this.options = options
}
render (container, callback) {
let node = null
container = container || this.options.container
if (!container) throw new Error(`Container is required: ${container}`)
if (!(container instanceof HTMLElement)) {
node = window.document.getElementById(container)
if (!node) throw new Error(`Container not found, window.document.getElementById: ${container}`)
} else {
node = container
}
if (!callback) {
callback = () => {}
}
return render(<GitalkComponent options={this.options}/>, node, callback)
}
}
module.exports = Gitalk