Giter Site home page Giter Site logo

Hide params from URL about web HOT 4 OPEN

react-navigation avatar react-navigation commented on April 29, 2024 4
Hide params from URL

from web.

Comments (4)

divonelnc avatar divonelnc commented on April 29, 2024 1

I am also porting my RN project to web and would like to hide the params from the URL.
I am sending an object as a route param to a new page and my URL is polluted with something like
http://localhost:19006/undefined?group=%5Bobject%20Object%5D

Besides this example, I would like to generally not show the params in the URL. Is there any way to hide them?

from web.

509dave16 avatar 509dave16 commented on April 29, 2024

@steventilator A better way to handle this is to have the constructor or componentDidMount assign the function to a file level scoped variable that then would get used in your navigationOptions callback. Would have to have a dummy function assigned or check for undefined/null in case navigationOptions gets called before componentDidMount/constructor.

from web.

MahmonirB avatar MahmonirB commented on April 29, 2024

I have same problem with hiding params in URL but I don't send it as params, when component request an API call with some filters, this filter is added to url. How can I prevent it?
thanks

from web.

alessiocancian avatar alessiocancian commented on April 29, 2024

I removed them adding the following custom getPathFromState to linkingOptions.
This code removes all object and function parameters from the url.

const linking = {
  config: {
    screens: {
      ...
    }
  },
  getPathFromState: (state, options) => {
    const cleanState = {
      ...state,
      routes: state.routes.map(route => {
        if(!route.params) {
          return route
        }

        const cleanParams = {}
        for(const param in route.params) {
          const value = route.params[param]
          if(typeof value !== "object" && typeof value !== "function") {
            cleanParams[param] = value
          }
        }
        return {
          ...route,
          params: cleanParams,
        }
      }),
    }
    return getPathFromState(cleanState, options) //imported from @react-navigation/native
  },
}

from web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.