-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
53 lines (49 loc) · 1.25 KB
/
Copy pathApp.js
File metadata and controls
53 lines (49 loc) · 1.25 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
/* eslint-disable camelcase */
// import './App.css';
import React, { useState, useReducer } from "react";
import Cell from "./Cell";
import { reducer } from "./reducer";
import { makeGlobal, downLoad_notebook, load_notebook } from "./utils";
import Layout from "./components/layout/layout";
import NavBar from "./components/NavBar/navbar";
const defaultState = {
cells: [{ id: "cell_1", input: "", output: "", type: "code" }],
};
function App() {
const [state, dispatch] = useReducer(reducer, defaultState);
const [currentCell, setCurrentCell] = useState(null);
makeGlobal();
return (
<Layout>
<NavBar />
<button
onClick={() => {
downLoad_notebook(state);
}}
>
Download Notebook
</button>
<input
type="file"
id="import-notebook-file"
onChange={() => {
load_notebook(dispatch);
}}
></input>
<br />
{state.cells.map((cell, index) => {
return (
<Cell
key={cell.id}
cell={cell}
dispatch={dispatch}
currentCell={currentCell}
setCurrentCell={setCurrentCell}
cellId={index + 1}
/>
);
})}
</Layout>
);
}
export default App;