ReactUnity / core

React and HTML framework for Unity UI & UIToolkit
https://reactunity.github.io/
MIT License
723 stars 38 forks source link

What's the best practice to use Router? #86

Closed lwyj123 closed 1 year ago

lwyj123 commented 1 year ago

I noticed that react-unity have a https://github.com/ReactUnity/full-sample/tree/134d65bd4c0f273ac511b40b0ee64c7e28ce3890. which use MemoryRouter but it seems like this method is not allowed to use url path directly.

is there a way to create a application that can be route using url path?

like localhost:3000/home

KurtGokhan commented 1 year ago

ReactUnity doesn't have a history API, and that is why MemoryRouter is used. If you want to sync the browser's url with ReactUnity url, that is a very complicated topic. You must be an expert in interacting with browser scripting.

You may access the browser window in ReactUnity with $$webglWindow. So you can do things like:

global['history'] = global.$$webglWindow['history'];

I don't know how this would work though. It is uncharted teritory 😁

Let me know if this answers your question.

KurtGokhan commented 1 year ago

We have a section mentioning MemoryRouter in FAQ. Closing this.