"Lightning SDK 4.0.0"

Some breaking Router changes

February 4, 2021

This new Lightning SDK version introduces a complete refactoring of the Router Plugin. The amount of features and the requests for additional features grew so fast, that we needed a more sustainable codebase. During rewrite, however, some potentially error-prone behavior occurred.

Because we wanted to get rid of this error-prone behavior, we had to introduce a breaking change which we will shortly discuss here.

Dynamic route properties

Let's say, we have the following route blueprint: {path: home/browse/:section} and we start a new navigation request: Router.navigate("home/browse/adventure").

In the previous release, the Router would make the data object { section: "adventure" } available to the page instance by directly setting the property on the page instance: page.section = "adventure".

This could lead to unwanted behavior. In the new release, the data object has been encapsulated and made available by calling _onUrlParams on the page instance:

class Browse extends Lightning.Component { _onUrlParams(args) { const section = args.section } }

The data object can still be used in the data provider callback:

{ path: home/browse/:section, component: Browse, before: async(page, {section}) => { // call some method on the page with section as argument page.handleSectionChange(section) } }

NOTE: Inspect your codebase for the use of route-provided page properties after you have upgraded to this new SDK version.