GithubHelp home page GithubHelp logo

Comments (7)

Starotitorov avatar Starotitorov commented on May 23, 2024

A higher order function is a function that takes a function as an argument, or returns a function.
In our case all functions like handleMerchantMessage, handleMerchantNotice, handleDeferredDeeplink, handleCallBack should return functions.

export const handleMerchantMessage = () => () => {
    pushNotificationBase();
}

export const handleMerchantNotice = () => () => {
    pushNotificationBase();
}

export const handleDeferredDeeplink = () => () => {
}

export const handleCallBack = () => () => {
    pushNotificationBase();
}

Recompose, redux-thunk packages have similar API. The idea behind this is to merge data from several sources, in this case some parameters are stored in closure.

handleMerchantMessage function receives the result of url parsing, the function returns another function which receives component props as an argument.

export const handleMerchantMessage = ({ scheme, route, query, params }) => ({ dispatch }) => {
}

Also, where did you find this code in the docs? The package does not provide such API. 😅

query: {
    "state": "state",
    "session_state": "session_state",
    "code": "code",
}

from react-native-deep-link.

haveamission avatar haveamission commented on May 23, 2024

Oops, my fault on the query part - I misinterpreted something written in the docs.

And thank you, that worked.

from react-native-deep-link.

haveamission avatar haveamission commented on May 23, 2024

Also, how would I wrap the function in a router correctly?

Like so?

const handleMerchantMessagePre = () => () => {
pushNotificationBase();
}

const handleMerchantMessage = withRouter(handleMerchantMessagePre);

from react-native-deep-link.

Starotitorov avatar Starotitorov commented on May 23, 2024

withRouter is a HOC, only React components can be wrapped with HOCs.

So, you should do something like this:

export default compose(
  withRouter,
  createDeepLinkingHandler(schemes)
)(YourComponent)

withRouter will pass some props to the WrappedComponent. This props will be available in your callback handler:

const handleMerchantMessage = () => ({ location, history, dispatch }) => {
  // Now you have access to the history and location here in the code
}

from react-native-deep-link.

haveamission avatar haveamission commented on May 23, 2024

Beautiful, thank you!

from react-native-deep-link.

Starotitorov avatar Starotitorov commented on May 23, 2024

Query parameters are not a part of pathname, you should omit them in route expression. are not a part of pathname, you should omit them in the route expression.

{    
    name: 'https:',
    routes: [
        {
            expression: 'company.onelink.me/QOVp/d8e6a2e0',
             callback: handleDeferredDeeplink
        }
    ]
}

from react-native-deep-link.

Starotitorov avatar Starotitorov commented on May 23, 2024

I am going to close the issue. Feel free to reopen it in case you have more questions.

from react-native-deep-link.

Related Issues (10)

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.