-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathDynamicallyChangingOptions.tsx
43 lines (40 loc) · 1.08 KB
/
DynamicallyChangingOptions.tsx
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
import SimpleMdeReact from "../SimpleMdeReact";
import { useState } from "react";
import { Options } from "easymde";
import React from "react";
import {State} from "./UpdateUsingButtonWithAutofocus";
export const DynamicallyChangingOptions = () => {
const [value, setValue] = useState(`Blur away to see initial event behavior`);
const [options, setOptions] = useState<Options>({
maxHeight: "50px",
});
return (
<div>
<h4>Dynamically changing options. Change max height</h4>
<button
onClick={() => {
setOptions((it) => {
return {
maxHeight: Number(it.maxHeight?.split("px")[0]) + 10 + "px",
};
});
}}
>
+
</button>
<button
onClick={() => {
setOptions((it) => {
return {
maxHeight: Number(it.maxHeight?.split("px")[0]) - 10 + "px",
};
});
}}
>
-
</button>
<State value={value} />
<SimpleMdeReact options={options} onChange={setValue} value={value} />
</div>
);
};