Ionic-framework: DeepLinker no longer works

Created on 6 Apr 2017  路  9Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
3.0

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
App wont compile after upgradnig to 3.0 from 2.3 becuase of DeepLinkerConfig
Error:
Argument of type '{ links: ({ component: typeof Home; name: string; segment: string; } | { component: typeof CardLi...' is not assignable to parameter of type 'DeepLinkConfig'. Types of property 'links' are incompatible.

Expected behavior:
App should compile with the deeplinker conifg

Steps to reproduce + Releated code:
Import DeepLinkerConfig in your IonicModule:

IonicModule.forRoot(MyApp, {
      locationStrategy: 'hash',
    },
     {links: [
        { component: Home, name: 'My Home', segment: '' },
      ]}),

Other information:
Ionic 3.0

reply

All 9 comments

Thanks for the issue! That format doesn't look correct. Can you try the following:

    IonicModule.forRoot(MyApp, {}, {
     links: [
      { component: Home, name: 'My Home', segment: '' }
    ]})

Here are the old docs on it: http://ionicframework.com/docs/2.3.0/api/navigation/DeepLinker/

You could also update to the new @IonicPage decorator which automatically sets up the DeepLink Config for you: http://ionicframework.com/docs/api/navigation/IonicPage/

Thanks @brandyscarney , Seem like I misstyped the concifg in this issue, but the deeplinkerconfig is not working the old way anymore.
I also updated to the new @IonicPage

@theunreal Which part isn't working? Is it still throwing that error for you?

I have the same issue.

IonicModule.forRoot(MyApp, {}, {
      links: [
        { component: HomePage, name: 'Home', segment: 'home' },
        { component: ContactPage, name: 'Contact', segment: 'contact' },
        { component: AboutPage, name: 'About', segment: 'about', defaultHistory:[HomePage] },
      ]
    })

The compliler is complaining about the types mismatch:

Argument of type '{ links: ({ component: typeof ContactPage; name: string; segment: string; } | { component:
typeof...' is not assignable to parameter of type 'DeepLinkConfig'. Types of property 'links' are
incompatible. Type '({ component: typeof ContactPage; name: string; segment: string; } | { component: typeof
AboutPag...' is not assignable to type 'DeepLinkMetadata[]'. Type '{ component: typeof ContactPage; name:
string; segment: string; } | { component: typeof AboutPage...' is not assignable to type 'DeepLinkMetadata'.
Type '{ component: typeof AboutPage; name: string; segment: string; defaultHistory: typeof HomePage[]; }' is
not assignable to type 'DeepLinkMetadata'. Types of property 'defaultHistory' are incompatible. Type 'typeof
HomePage[]' is not assignable to type 'string[]'. Type 'typeof HomePage' is not assignable to type 'string'.

But I am quite sure that for me the problem is caused by this property defaultHistory:[HomePage]. If it's removed, the code compiles without errors.

I suppose, the prpblem is here:

Types of property 'defaultHistory' are incompatible. Type 'typeof
HomePage[]' is not assignable to type 'string[]'. Type 'typeof HomePage' is not assignable to type 'string'.

If I pass not the component object, but a string (like this defaultHistory:['HomePage']), the code compiles without errors. But, of course, I get a runtime error Uncaught (in promise): invalid link: HomePage

@yamov Thank you so much for the steps to reproduce! We will look into this immediately.

I ran into this issue while upgrading to Ionic 3. Ideally the v2 solution would work with v3 if you simply switch to using strings, but I ran into some issues while trying to get that working. I figured if I was upgrading to v3, I should use the new features for deep link configuration.

Ionic 3 allows using strings instead of objects for navigation to enable lazy loading of components. In order to take advantage of these improvements, I had to make use of the IonicPage decorator for all my pages. The IonicPage decorator allows defining the deep link configuration on a page by page basis. I also ended up integrating the usage of IonicPageModule for all my pages. Once my pages were in the v3 format, and after making a necessary bug fix (https://github.com/driftyco/ionic/pull/11131), I was able to get deep linking working.

cannot navigate with string path.

this.navCtrl.push("{path of segment}");

Failed to navigate: undefined
ERROR Error: Uncaught (in promise): invalid link: leases

This is resolved now. defaultHistory once again accepts a component instead of just strings.

Thanks,
Dan

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrBokeh picture MrBokeh  路  3Comments

masimplo picture masimplo  路  3Comments

SebastianGiro picture SebastianGiro  路  3Comments

danbucholtz picture danbucholtz  路  3Comments

brandyscarney picture brandyscarney  路  3Comments