Paul SOUTEYRAT
07/07/2021, 2:40 PMkotlin-react
and I saw that hooks' usage has changed and older usage has been deprecated. Overall this change seems good because it brings consistency (using vararg). However, I have a slight issue because I wish to use useEffect
with the new usage, but I can't when passing a single dependency which is either a list or a dynamic variable.
For instance:
useEffect(myDynamicVariable) {
//EffectBuilder
}
With this code IntelliJ warns about deprecation, and, when running, Uncaught TypeError: collection.iterator is not a function
is thrown because myDynamicValue
is interpreted as a list.
The same issue occurs when passing a single list as the only dependency (even though it does not throw a TypeError).
Any idea on how I can fix this issue ?Lazard
07/07/2021, 7:30 PMbsimmons
07/12/2021, 2:39 PMrouteLink("/contact") {
ref {
it?.style?.textDecoration = "none"
it?.style?.color = "inherit"
}
+"Jane Rogers"
}
Paul SOUTEYRAT
07/25/2021, 8:01 PMbsimmons
07/26/2021, 1:16 PMcfnz
07/29/2021, 10:17 PMbsimmons
08/04/2021, 12:09 PMjoney
08/04/2021, 8:36 PMkotlin-wrappers-bom:0.0.1-pre.213-kotlin-1.5.10
works just fine. For newer versions compileKotlinJs
fails with Unresolved reference: react
even though the IDE does not complain and the source files get resolved.
Any hints? I tried clean and invalidate caches/restart....
(:kotlinnew: 1.5.21
and :gradle: 7.1.1
)GUIGAL Allan
08/09/2021, 11:50 PMcfnz
08/12/2021, 10:52 PMrenderOption={(option) => (
<React.Fragment>
<span>
{option.label}
</span>
</React.Fragment>
)}
In my Kotlin code, it used to be like this:
renderOption = { option, _ ->
Fragment {
span {
+option.label
}
}
}
What is the recommended way of doing this now?Mark
08/20/2021, 4:59 PMBrowserDevelopmentRun in continuous mode
task, it ran fine, however the localhost did not pop in my browser, going to localhost:8080
doesn't seem to have anything This site can't be reached
, same for :3000
. In the run window in IJ there is a warning:
[webpack-cli] Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
- configuration has an unknown property '_assetEmittingWrittenFiles'. These properties are valid:
object { bonjour?, client?, compress?, dev?, firewall?, headers?, historyApiFallback?, host?, hot?, http2?, https?, liveReload?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, public?, setupExitSignals?, static?, transportMode?, watchFiles? }
Happens both with IR and Legacy.andylamax
09/04/2021, 11:20 AMkotlin-react.
A lot of things are now very consistent.
Follow question though. I see that we have
interface RBuilder {
// . . .
fun <P : Props> child(
klazz: KClass<out Component<P, *>>,
handler: RHandler<P>,
)
// . . .
}
Question is, why don't we have
interface RBuilder {
// . . .
fun <P : Props> child(
klazz: KClass<out Component<P, *>>,
props: P,
handler: RHandler<P>,
)
// . . .
}
So that I may
child(Hellow::class,jsObject{
param1 = 1
param2 = 2
param3 = "three"
// . . .
})
instead of
child(Hellow::class) {
attrs {
param1 = 1
param2 = 2
param3 = "three"
}
}
andylamax
09/10/2021, 11:02 PMpeerDependency
and avoid it being bundled in the final build? That way the it will be bundled with the consumer's version of react?
If this is not possible now, is it possible in the future (near or far)?calrissian
09/12/2021, 9:36 PMNikola Milovic
09/16/2021, 11:48 AMval MainScreen = fc<MainProps> { props ->
...
sidebar { // has props with children
when (child) { // this causes crash
is Main.Child.Chat -> p{attrs.text("heloooo test")}
else -> p{attrs.text("heloooo error")}
}
}
}
external interface SidebarProps : PropsWithChildren {
}
val sidebar = fc<SidebarProps> { props ->
props.children?.forEach {
child(it)
}
}
CLOVIS
09/17/2021, 9:08 AMchild(MyClassComponent::class) {
child(SomeFunctionalComponent)
}
then, in MyClassComponent.render:
if (...) {
props.children()
}
This works fine with run
, but fails with `browserProductionWebpack`:
TypeError: _.render is not a function
The commit with the full code (1 class component + its call), the version details. Originally posted in #javascript (here) but I was redirected here.nordiauwu
09/21/2021, 3:23 PMPitel
09/22/2021, 8:13 AMStateInstance
delegate in Props
? 🤔 So then child components could easily change state of parent component.Nicodemus Ojwee
09/23/2021, 6:47 AMthis.setState(state => ({
...state,
stack: [...state.stack, state.sceneConfig[sceneName]],
}), () => {
// Do something here
});
Nikola Milovic
09/27/2021, 9:51 AMval chatSidebar = fc<ChatProps> { props -> // the fc that I want to pass
-----
external interface SidebarProps : PropsWithChildren {
var sidebarContent: FunctionComponent<Props> // want to pass it here
}
val sidebar = fc<SidebarProps> { props ->
div { props.sidebarContent } // somehow do something like this
props.children() //already using children for the main content
This is how I want to use the sidebar
sidebar {
when (child) {
is Main.Child.Chat -> {
attrs.sidebarContent = chatSidebar{} // add the corresponding content to the props alongside the main content
chat { attrs.component = child.component} // the child/ main content
Pitel
10/04/2021, 12:52 PMPropsWithChildren
? Will the element(s) added there be automaticaly rendered? And what the difference with ReactNode.unaryPlus()
in RBuilder
?Nikola Milovic
10/06/2021, 3:54 PMreact-hook-form
wrapper
form {
attrs.onSubmitFunction = {
console.log("Submit")
}
attrs.onSubmit = {
console.log("Submit")
}
input(classes = defaultButtonStyle, type = InputType.submit) {
}
}
Tried it with intput of type submit and with button of type submit, both refresh the page and nothing gets logged in the console. (Prevent default for button did work for preventing the refresh but it didn't log anything)Nikola Milovic
10/09/2021, 8:40 AMfun getDefaultValuesFromProfile(profile: ProfileModel): dynamic {
val d : dynamic = js("{ defaultValues : {...profile}}")
return d
}
Which should be totally valid in ts (javascript)
function test(profile: IProfile) {
const test = { defaultValues: { ...profile } };
}
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)Pitel
10/29/2021, 8:43 AMSnackContext.Provider {
attrs.value.showError = { errorSnack = true}
This fails with Uncaught TypeError: Cannot set properties of undefined (setting 'showError')
.Mihai Voicescu
11/11/2021, 2:47 PMvar chats by useState(listOf<String>("first"))
useEffectOnce {
GlobalScope.launch {
client.rtmStream().collect {
val current = chats // always initial value
println(current)
chats = current + it.message
}
}
}
Am I doing something wrong?gbaldeck
11/17/2021, 3:18 AMPiotr Krzemiński
11/17/2021, 7:56 AMToby
11/20/2021, 9:42 AMnordiauwu
11/24/2021, 1:29 PMnordiauwu
11/24/2021, 1:29 PMturansky
11/24/2021, 1:58 PMnordiauwu
11/24/2021, 5:04 PMturansky
11/24/2021, 5:53 PMnordiauwu
11/24/2021, 6:12 PMconfig.externals = {
'react': 'React',
'react-dom': 'ReactDOM'
}