Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WASM BrowserRouter] Failed to navigate: Maximum call stack exceeded #421

Open
exaucae opened this issue Nov 26, 2024 · 0 comments
Open

Comments

@exaucae
Copy link

exaucae commented Nov 26, 2024

Summary: I'm unable to navigate to another screen in a wasmjs app. Individual routes /hello and /world are accessible when directly entered in the browser; Webpack devser config has also been properly added.

Dependency version:

wasmJsMain.dependencies {
  implementation("app.softwork:routing-compose:0.4.0")
 }

Reproducible steps:

// webpack.config.d/config.devServer.js
config.devServer = {
    ...config.devServer, // Merge with other devServer settings
    "historyApiFallback": true
};
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import app.softwork.routingcompose.BrowserRouter
import app.softwork.routingcompose.Router
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.ComposeViewport
import kotlinx.browser.document

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
    val body = document.body ?: throw IllegalStateException("No document.body")
    ComposeViewport(body) {
        App()
    }
}

@Composable
internal fun App() {
    BrowserRouter(initPath = "/hello") {
        route("/hello") {
            Hello()
        }
        route("/world") {
            World()
        }
    }
}

@Composable
fun Hello() {
    val router = Router.current
    Text("Hello World")
    Button(onClick = { router.navigate("/world") }) {
        Text("Go to World")
    }
}

@Composable
fun World() {
    val router = Router.current
    Text("World")
    Button(onClick = { router.navigate("/hello") }) {
        Text("Go to Hello")
    }
}

image

On Click, here's the browser webpack error:

Uncaught runtime errors:
×
ERROR
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f598e)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
    at <my.app:web>.app.softwork.routingcompose.pushState (http://localhost:8080/web.wasm:wasm-function[65617]:0x8f5997)
@exaucae exaucae changed the title [WASM] Failed to navigate: Maximum call stack exedeed [WASM] Failed to navigate: Maximum call stack excedeed Nov 26, 2024
@exaucae exaucae changed the title [WASM] Failed to navigate: Maximum call stack excedeed [WASM] Failed to navigate: Maximum call stack exceeded Nov 26, 2024
@exaucae exaucae changed the title [WASM] Failed to navigate: Maximum call stack exceeded [WASM BrowserRouter] Failed to navigate: Maximum call stack exceeded Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant