Pitel
10/18/2021, 2:16 PMconsole.log(props.text.language?.id)
val updateText = { newText: String ->
console.log("updateText ${props.text.language?.id}")
props.update(props.text.copy(body = newText))
}
val cm = useCodeMirror(jsObject {
console.log("jsObject ${props.text.language?.id}")
container = editor.current
basicSetup = false
extensions = arrayOf(
StreamLanguage.define(mai),
defaultHighlightStyle.fallback as Any
)
onChange = { text, _ ->
console.log("onChange ${props.text.language?.id}")
updateText(text)
}
height = "300px"
value = props.text.body ?: ""
})
This is in the body of functional component.
When run the first time, it looks ok, all logs shows language id 1
. But, when I pass new props, something weird happens:
2
jsObject 2
onChange 1
updateText 1
Any idea why the onChange
and updateText
keeps the old value?!
(The source of `useCodeMirror`: https://github.com/uiwjs/react-codemirror/blob/master/src/useCodeMirror.ts)turansky
10/18/2021, 2:33 PMPitel
10/18/2021, 2:51 PMturansky
10/18/2021, 3:35 PMturansky
10/18/2021, 3:44 PMPitel
10/18/2021, 3:47 PMjsObject
with configuration, with dependency on language id. Didn't helped. 😞turansky
10/18/2021, 3:57 PMCLOVIS
10/18/2021, 4:09 PMCLOVIS
10/18/2021, 4:11 PMPitel
10/19/2021, 6:37 AMPitel
10/19/2021, 6:42 AMonChange
(depending on language id), and I;m still getting the old value.