hannesstruss
10/04/2020, 11:18 AMBjörn Mayer
10/25/2020, 1:35 PMJoost Klitsie
10/29/2020, 6:27 PM<ReactPlayer
config={{
file: {
hlsOptions: {
forceHLS: true,
debug: false,
xhrSetup: function(xhr, url) {
if (needsAuth(url)) {
xhr.setRequestHeader('Authorization', getToken())
}
},
},
},
}}
/>
I saw the things on https://play.kotlinlang.org/hands-on/Building%20Web%20Applications%20with%20React%20and%20Kotlin%20JS/07_Using_Packages_From_NPM but I can't wrap my head around itMarc Knaup
11/16/2020, 6:49 PM@Suppress("unused")
fun RBuilder.useCoroutineScope(): CoroutineScope {
val (scope) = useState { CoroutineScope(GlobalScope.newCoroutineContext(Dispatchers.Unconfined)) }
useEffectWithCleanup(emptyList()) { { scope.cancel() } }
return scope
}
In component:
val scope = useCoroutineScope()
scope.launch { … }
Big Chungus
11/25/2020, 11:27 AM#1
fun RBuilder.Component(prop1:String, prop2:String) {}
#2
interface ComponentProps: RProps {
var prop1: String
var prop2: String
}
val Component = rFunction<ComponentProps>("Component"){}
andylamax
11/25/2020, 6:43 PMEnzyme
? Before I go down this road?igor.wojda
12/15/2020, 8:15 PMReact + Kotlin
vs React + JS/TS
?
2. Is it worth a hustle to use React + Kotlin
only because I like Kotlin
?
3. How mature it is in terms of tools and external libraries compatibility?
4. What are the main disadvantages currently?andylamax
12/20/2020, 3:53 AMRComponent
and you override
methods with arguments that are called from react
directly (i.e. componentDidUpdate(prevProps,prevState,snapshot)
or componentWillReceiveProps(nextProps)
), generated javascript
code always throws a ClassCastException
.
Lets take a look at componentWillReceiveProps(next)
. The IR Compiler
generates javascript
code similar to this
PaginatedGridComp.prototype.componentWillReceiveProps = function (nextProps) {
return this.componentWillReceiveProps_17(nextProps instanceof Props_19 ? nextProps : THROW_CCE());
};
Since react
creates nextProps
internally, the check nextProps instanceof Props_19
always fails. Hence it throws CCE
Is there a work around to this problem?
IR Compiler Backendepabst
12/29/2020, 5:25 AMcfnz
01/21/2021, 2:09 AMconst StyledRating = withStyles({
iconFilled: {
color: '#ff6d75',
},
iconHover: {
color: '#ff3d47',
},
})(Rating);
export default function CustomizedRatings() {
return (
<div>
...
<StyledRating
name="customized-color"
defaultValue={2}
getLabelText={(value: number) => `${value} Heart${value !== 1 ? 's' : ''}`}
precision={0.5}
icon={<FavoriteIcon fontSize="inherit" />}
/>
...
How would I use/pass these StyledRatings styles to my component?
Kotlin - how do I add the iconFilled prop or style?:
...
mRating("customized-empty", value, precision = 0.5, onChange = { _, newValue -> valueCustom = newValue },
icon = mIcon("favorite", fontSize = MIconFontSize.inherit, addAsChild = false, color = MIconColor.inherit) {
css {
???
}
}
)
Big Chungus
02/04/2021, 8:17 AMManel Martos Roldan
02/11/2021, 9:32 AMTimo Gruen
02/13/2021, 10:22 AMNicodemus Ojwee
02/22/2021, 9:22 PMwillyrs
03/05/2021, 9:31 AMoverride fun RBuilder.render() {
browserRouter {
div {
ul {
li {
routeLink("/") { +"Home" }
}
li {
routeLink("/test") { +"Test" }
}
}
switch {
route("/") {
h1 {
+"Home path"
}
}
route("/test") {
h1 {
+"Test path"
}
}
}
}
}
}
What happens:
When I start the website, it prints "Home path". The I press "Test" in the menu, the url changes to http://localhost:8080/test but the header still says "Home path". If I then press F5 I have the error "Cannot GET /test".
What could be the problem? It seems the same as the tutorial that I'm looking atMarc Knaup
03/12/2021, 5:58 PMMarc Knaup
03/16/2021, 1:00 PMErdem
03/16/2021, 3:54 PMval (state, setState) = useState(emptyList<Post>())
provider.observePosts { list -> setState(list) }
With this method the ui only updates once, however if I set state like this setState(list.toList())
it works fine.
I am concerning about performance. How should I update my list?Robert Jaros
03/16/2021, 4:21 PMkotlin-wrappers
artifacts to JB Space and not to Maven Central?Alexey Artemiev
03/31/2021, 5:54 PMval x by css {
backgroundImage = require("src/main/resources/image.png")
}
gives an error
Module 'src/main/resources/image.png' not found
Moving file to main/kotlin/... and changing to relative path from the source file dir gives the same "not found" error. Using JsModule gives the same error too.
The advice require("image.png")
doesn't work either.
Where should resources be placed, and how to reference them by relative path in kotlin/js react app?
Please, help!
Google gives only 2-year (and more) old advices which don't help, because kotlin/js seems to have changed much recently.Robert Jaros
04/03/2021, 10:11 AMkotlin-styled
.Nicodemus Ojwee
04/06/2021, 7:11 PMUncaught TypeError: HTMLReactParser is not a function
This is how the module is defined.
@file:JsModule("html-react-parser")
@file:JsNonModule
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")
package libs
import react.ReactElement
external interface HTMLReactParserOptions {
var htmlparser2: Any? /* ParserOptions & DomHandlerOptions */
get() = definedExternally
set(value) = definedExternally
var library: dynamic
get() = definedExternally
set(value) = definedExternally
var replace: ((domNode: dynamic /* Comment | Element | Node | ProcessingInstruction | Text */) -> dynamic)?
get() = definedExternally
set(value) = definedExternally
var trim: Boolean?
get() = definedExternally
set(value) = definedExternally
}
@JsName("HTMLReactParser")
external fun parse(html: String, options: HTMLReactParserOptions = definedExternally): ReactElement
rishi jha
04/15/2021, 4:45 PMPaul SOUTEYRAT
04/17/2021, 11:11 AMinterface MyGenericCompProps<T> : RProps
fun <T> myGenericComp() = { props: MyGenericCompProps<T> ->
buildElement {
div {
+"Generic component"
}
}
}
val genericCompContainer = functionalComponent<RProps> {
child(myGenericComp<Any>())
}
But I am not sure if it's a good way to make a component.
Do any of you see issues with my example ?andylamax
05/01/2021, 9:37 PMCould not find "kotlinx-extensions" in [~/.local/share/kotlin/daemon]
. I checked the dependencies and I can find dependencies from the space repository. Even ./gradlew dependencies --configuration runtimeClasstimepath
shows the dependency is resolved.
What am I missing?Robert Jaros
05/05/2021, 4:22 PMkotlin-wrappers
artifacts for Kotlin 1.5.0 published to Maven Central soon?Big Chungus
05/12/2021, 1:00 PMCurrently there are multiple ways of doing the same react stuff in kotlin-react (e.g. rComponent() vs functionalComponent()). My understanding (based on various threads on this in the past) is that this came to be mainly because of the way kreact evolved over the years and more mature APIs surfaced. Have you had any thoughts of cleaning this up with deprecations to reduce confusion for new folks trying kreact out?
andylamax
06/07/2021, 3:52 AMRobert Jaros
06/13/2021, 11:03 AMRoman Vasilyev
07/04/2021, 7:26 AMreactJs.js
is it possible to change config to get reactJs.somerandomhash.js
?