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

Allow Guarded containers to be ReactNode, not only ComponentClass #15

Merged
merged 4 commits into from
Apr 1, 2019

Conversation

kbouchard
Copy link
Contributor

Fixes this restriction:
Screen Shot 2019-04-01 at 9 58 37 AM
Screen Shot 2019-04-01 at 9 58 48 AM

isGuarded: boolean;
}

export function createDisabledContainer (WrappedComponent: React.ComponentClass<any>): React.ComponentClass {
export function createDisabledContainer (WrappedComponent: React.ComponentType<any>): React.ReactNode {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

WrappedComponent: React.ReactNode here wouldn't work, it would trigger issues w/ constructor call signature.

@@ -45,7 +45,7 @@ export function createDisabledContainer (WrappedComponent: React.ComponentClass<
export function createGuardedContainer ({ isGuarded, enabledComponent, disabledComponent }: IGuardedContainerProps): React.ComponentClass {
@observer
class GuardedContainer extends Component {
private readonly GuardedComponent: React.ComponentClass;
private readonly GuardedComponent: any;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know this isn't optimal, but I spend a lot of time trying to figure that one out.
The issue is that we're setting that value after the constructor has triggered, so it would technically need to be :
private readonly GuardedComponent: React.ComponentClass<any> | {} | null | undefined;

Which felt ... messy || not efficient enough to justify it ?

Let me know what you think.

@kbouchard kbouchard merged commit 56009c9 into master Apr 1, 2019
@rpalermodrums rpalermodrums deleted the allow-guarded-reactnode branch June 24, 2019 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants