forked from popcodeorg/popcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreview.js
More file actions
63 lines (54 loc) · 1.42 KB
/
Preview.js
File metadata and controls
63 lines (54 loc) · 1.42 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {connect} from 'react-redux';
import Preview from '../components/Preview';
import {
addRuntimeError,
consoleErrorProduced,
consoleLogProduced,
consoleValueProduced,
popOutProject,
refreshPreview,
} from '../actions';
import {
getCompiledProjects,
getConsoleHistory,
getFocusedSelector,
isCurrentProjectSyntacticallyValid,
isUserTyping,
} from '../selectors';
function mapStateToProps(state) {
return {
compiledProjects: getCompiledProjects(state),
consoleEntries: getConsoleHistory(state),
focusedSelector: getFocusedSelector(state),
showingErrors: (
!isUserTyping(state) &&
!isCurrentProjectSyntacticallyValid(state)
),
};
}
function mapDispatchToProps(dispatch) {
return {
onConsoleError(key, name, message, compiledProjectKey) {
dispatch(consoleErrorProduced(key, name, message, compiledProjectKey));
},
onConsoleValue(key, value, compiledProjectKey) {
dispatch(consoleValueProduced(key, value, compiledProjectKey));
},
onConsoleLog(value, compiledProjectKey) {
dispatch(consoleLogProduced(value, compiledProjectKey));
},
onPopOutProject() {
dispatch(popOutProject());
},
onRefreshClick() {
dispatch(refreshPreview(Date.now()));
},
onRuntimeError(error) {
dispatch(addRuntimeError('javascript', error));
},
};
}
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Preview);