agrcrobles / react-native-web-boilerplate

I am no longer in maintenance
71 stars 11 forks source link

How to get the parameters on the URL? #11

Closed damiaozi closed 7 years ago

damiaozi commented 7 years ago

I use react-navigation Do interface jump. but,now,I want to get the parameters on the URL。 How to get the parameters on the URL?

agrcrobles commented 7 years ago

Hi,

In order to rewrite the url, ( add history etc ) you will have to implement your custom BrowserAppContainer in your web app.

I remind you it is suggested not using native navigators on web. You can create your custom navigator extending either TabRouter or StackRouter.

If you can make the URL rewrite work without REDUX, feel free to send a PR, I can review it.

Thanks

damiaozi commented 7 years ago

I get parameters by this way.but I do not know whether this is a viable way

 export function paraURL(paramName) {
    paramValue = "", isFound = !1;  
    if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {  
        arrSource = unescape(this.location.search).substring(1, this.location.search.length).split("&"), i = 0;  
        while (i < arrSource.length && !isFound) arrSource[i].indexOf("=") > 0 && arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase() && (paramValue = arrSource[i].split("=")[1], isFound = !0), i++  
    }  
    return paramValue == "" && (paramValue = null), paramValue  

}