1
- import React , { useState } from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
import Select from "react-select" ;
3
3
import { SerialPlotter } from "./utils" ;
4
4
@@ -14,6 +14,14 @@ export function MessageToBoard({
14
14
const [ baudRate , setBaudrate ] = useState ( config . currentBaudrate ) ;
15
15
const [ lineEnding , setLineEnding ] = useState ( config . currentLineEnding ) ;
16
16
17
+ useEffect ( ( ) => {
18
+ setBaudrate ( config . currentBaudrate ) ;
19
+ } , [ config . currentBaudrate ] ) ;
20
+
21
+ useEffect ( ( ) => {
22
+ setLineEnding ( config . currentLineEnding ) ;
23
+ } , [ config . currentLineEnding ] ) ;
24
+
17
25
const lineendings = [
18
26
{ value : "" , label : "No Line Ending" } ,
19
27
{ value : "\n" , label : "New Line" } ,
@@ -28,6 +36,7 @@ export function MessageToBoard({
28
36
29
37
const wsSend = ( command : string , data : string ) => {
30
38
if ( websocket && websocket ?. current ?. readyState === WebSocket . OPEN ) {
39
+ console . log ( "send" ) ;
31
40
websocket . current . send (
32
41
JSON . stringify ( {
33
42
command,
@@ -62,7 +71,7 @@ export function MessageToBoard({
62
71
< Select
63
72
className = "singleselect lineending"
64
73
classNamePrefix = "select"
65
- defaultValue = {
74
+ value = {
66
75
lineendings [ lineendings . findIndex ( ( l ) => l . value === lineEnding ) ]
67
76
}
68
77
name = "lineending"
@@ -84,9 +93,7 @@ export function MessageToBoard({
84
93
< Select
85
94
className = "singleselect"
86
95
classNamePrefix = "select"
87
- defaultValue = {
88
- baudrates [ baudrates . findIndex ( ( b ) => b . value === baudRate ) ]
89
- }
96
+ value = { baudrates [ baudrates . findIndex ( ( b ) => b . value === baudRate ) ] }
90
97
name = "baudrate"
91
98
options = { baudrates }
92
99
menuPlacement = "top"
0 commit comments