Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Outlet from a HOC to a standard component with a render prop #63

Merged
merged 9 commits into from
Aug 16, 2018

Conversation

agubler
Copy link
Member

@agubler agubler commented Aug 13, 2018

Type: feature

The following has been addressed in the PR:

Description:

This changes the Outlet from a higher order component to a standard component with a render property. The render property is used to display content when a route matches providing more control over the nodes to render when an Outlet's route has been matched.

Having an Outlet as a HOC implies that it would be shared across the application (which generally they are not), adds complexity in it's usage by having to specify another interface for the properties that the Outlet can accept and has more boilerplate and indirection that if the Outlet is a standard widget.

render() {
    return v('div', [
        w(Outlet, { 
            id: 'outlet-name', 
            renderer: (matchDetails: MatchDetails) => {
                // match details contains the `matchType`, `params` and `queryParams`
                return v(MyWidget, { foo: 'bar', id: matchDetails.id });
            }
        })
    ]);
}

Resolves #60

Alternative to #24

@agubler agubler changed the title Convert Outlet from a HOC to a standard component with a render prop [WIP] Convert Outlet from a HOC to a standard component with a render prop Aug 13, 2018
@agubler agubler changed the title [WIP] Convert Outlet from a HOC to a standard component with a render prop Convert Outlet from a HOC to a standard component with a render prop Aug 13, 2018
key?: RegistryLabel;
mapParams?: MapParams;
}
export interface MatchDetails {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is OutletDetails a better name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think MatchDetails is more appropriate as it's the details for the current match, not the outlet as a whole. Perhaps MatchProperties though?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want to overload properties

@agubler agubler mentioned this pull request Aug 15, 2018
3 tasks
@agubler agubler added enhancement New feature or request breaking change Indicates the issue/pull request would result in a breaking change next Issue/Pull Request for the next major version labels Aug 15, 2018
return Boolean(value && (typeof value === 'string' || typeof value === 'function' || typeof value === 'symbol'));
export interface OutletProperties {
renderer: (matchDetails: MatchDetails) => DNode;
outlet: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps rename to id ?

export function isComponent<W extends WidgetBaseInterface>(value: any): value is Component<W> {
return Boolean(value && (typeof value === 'string' || typeof value === 'function' || typeof value === 'symbol'));
export interface OutletProperties {
renderer: (matchDetails: MatchDetails) => DNode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not return an array of DNodes ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be able to.

@agubler agubler force-pushed the functional-outlet-as-widget branch from decc431 to d3877cb Compare August 16, 2018 10:46
@agubler agubler force-pushed the functional-outlet-as-widget branch from 528be9f to 2e592b9 Compare August 16, 2018 17:11
@agubler agubler merged commit b1a7ef5 into dojo:master Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Indicates the issue/pull request would result in a breaking change enhancement New feature or request next Issue/Pull Request for the next major version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants