MCPcopy Create free account
hub / github.com/dabbott/javascript-playgrounds / componentDidMount

Method componentDidMount

components/workspace/PlayerFrame.js:43–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 }
42
43 componentDidMount() {
44 this.setState({
45 id: Math.random().toString().slice(2)
46 })
47
48 window.addEventListener('message', (e) => {
49 let data
50 try {
51 data = JSON.parse(e.data)
52 } catch (err) {
53 return
54 }
55
56 const {id, type, payload} = data
57
58 if (id !== this.state.id) {
59 return
60 }
61
62 switch (type) {
63 case 'ready':
64 this.status = 'ready'
65 if (this.fileMap) {
66 this.runApplication(this.fileMap, this.entry)
67 this.fileMap = null
68 this.entry = null
69 }
70 break
71 case 'error':
72 this.props.onError(payload)
73 break
74 case 'console':
75 this.props.onConsole(payload)
76 break
77 }
78 })
79 }
80
81 runApplication(fileMap, entry) {
82 this.props.onRun()

Callers

nothing calls this directly

Calls 1

runApplicationMethod · 0.45

Tested by

no test coverage detected