-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ export interface IDisabledContainerProps { | |
} | ||
|
||
export interface IGuardedContainerProps { | ||
disabledComponent: React.ComponentClass; | ||
enabledComponent: React.ComponentClass; | ||
disabledComponent: React.ReactNode; | ||
enabledComponent: React.ReactNode; | ||
isGuarded: boolean; | ||
} | ||
|
||
export function createDisabledContainer (WrappedComponent: React.ComponentClass<any>): React.ComponentClass { | ||
export function createDisabledContainer (WrappedComponent: React.ComponentType<any>): React.ReactNode { | ||
@observer | ||
class DisabledContainer extends Component<IDisabledContainerProps> { | ||
public static displayName = `DisabledContainer(${getDisplayName(WrappedComponent)})`; | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. Which felt ... messy || not efficient enough to justify it ? Let me know what you think. |
||
public static displayName = `GuardedContainer(${getDisplayName(enabledComponent)})`; | ||
|
||
public constructor (props: any) { | ||
|
There was a problem hiding this comment.
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.