Hi everyone, I updated to the latest version of th...
# javascript
f
Hi everyone, I updated to the latest version of the
kotlin-wrappers
lib and I noticed that the React wrapper has changed quite a bit and now I'm not sure how to do the following:
Copy code
route("${url}/:id") { props ->
    val idParam = props.match.params.id

    ...
}
Does anyone know how to do this with the new API? @turansky you might know 🙂
t
You can find answer here
f
Thanks for sharing that @turansky. I added a comment on that issue as I think there is a reason to keep the deprecated methods as they are useful. Apart from that however, the question I asked is not answered there. The example I shared is for the function that receives the property as a paramter to be able to extract parameter from the URL path. There is no mention of how to do that with the new APIs and the old method I was using seems to have been removed rather than deprecated?
t
You can use
useParams
hook instead.
useParams
available for any component inside
Route
f
Mh, seems like a really simple 1 line of code is now multiple complex lines of code that require deep understanding of the underlying works of the library. Which makes working with the library a lot harder for newcomers. Can you guys consider un-deprecating the extension functions and keeping them? I can create an issue in the repository with more details on why I think keeping them is a good idea for the library users if you want. I'm also happy to help maintain them if that is the reason why you decided to remove them.
t
Props
problems are common and they can have common solution. Extensions/adapters - backward step (we will describe details in issue)
f
Thanks @turansky 👍
a
@turansky but we can use useParam only in Function Component, right?
t
Yes. Function components also preferred for development
a
so, no option to transfer param to RComponent now (without Function Component)?
t
Simple option - wrap
RComponent
a
oh, thx! great, as at least temporary fix, do not want to rewrite all this code with states for now.
t
Or you can use
RouteComponentProps
as component props And use
match
property (check required)
a
Thank you so much @turansky. it also may be worth updating the readme at kotlin-react-router-dom to reflect recent changes. Its look dated. It's very difficult to understand resent changes in kotlin wrappers sometime.
👍 1
t
It’s common
react-router-dom
contract, non-specific for Kotlin