I can maximize and minimize with the SIZE button. But if the user changes the size of the editor window manually, the code doesn't work. How can I fix it?
I think I have to change the useState to take a non-boolean value, but I don't know to what.
Here's the App.js code
import { useState } from 'react';
import Editor from './components/Editor';
function App() {
const [content, setContent] = useState("")
function handleChange(event) {
setContent(event.target.value)
}
const [editorSize, setEditorSize] = useState(true)
function toggleEditorSize() {
setEditorSize(prevState => !prevState)
}
return (
<div className="App">
<Editor handleChange={handleChange} toggleEditorSize={toggleEditorSize} editorSize={editorSize}/>
</div>
);
}
export default App;
Here's the Editor.js code
export default function Editor(props) {
return (
<div>
<div className="editor-header">
<p className="editor-title">Editor</p>
<button onClick={props.toggleEditorSize}>SIZE</button>
</div>
<textarea id="editor" className={props.editorSize ? "max": ""} onChange={props.handleChange} >
</textarea>
</div>
)
}
Here's the Index.css code
background-color: white;
color: black;
border: 2px solid black;
position: relative;
display: inline-block;
overflow: scroll;
border-top: none;
min-width: 500px;
min-height: 300px;
max-width: 500px;
max-height: 600px;
height: 300px;
}
#editor.max, #preview.max {
height: 600px;
}