How to use Decompose in an SwiftUI project? #204
Unanswered
falcon4ever
asked this question in
Q&A
Replies: 1 comment 4 replies
-
First of all, your Compose integration sample has a mistake. If the composable block will be recomposed for any reason, a new instance of the val component = RootComponent(defaultComponentContext())
setContent {
NavigationSampleTheme {
RootUi(component)
}
} Now regarding the issue with Swift. Seems like in your Gradle file you should add |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
On Android/Compose it's pretty easy to get started using:
For my demo project, I'm trying to implement the SwiftUI version, but I'm struggling to figure out how to get the default component context.
I looked at the counter demo as well as the compose-jb todoapp example:
https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/ios/ios/ContentView.swift
https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/ios/ios/ComponentHolder.swift
And it seems like all of them are using a helper class
ComponentHolder
. The new component is created viaDefaultComponentContext
andLifecycleRegistryKt.LifecycleRegistry()
When I copy the same code into my SwiftUI project, I unfortunately get a bunch of warnings:
I don't seem to have a
DefaultComponentContext
the closest thing I can find isDecomposeComponentContext
(renamed from SharedDecomposeComponentContext according to xcode)For the lifecycle, I can't find the LifecycleRegistryKt
Are there any additional steps I need to do to get hold of the default component context and the lifecycle registry?
I'm using Decompose 0.3.1 and kotlin v1.5.21
Beta Was this translation helpful? Give feedback.
All reactions