Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
716 B
23 lines
716 B
import React from 'react';
|
|
import { Features } from './types';
|
|
|
|
export interface ApplicationContext {
|
|
features: Features;
|
|
}
|
|
|
|
const ApplicationContextDefaultValue = {} as ApplicationContext
|
|
export const ApplicationContext = React.createContext(
|
|
ApplicationContextDefaultValue
|
|
);
|
|
|
|
export function withAuthenticatedContexApplicationContext<T extends ApplicationContext>(Component: React.ComponentType<T>) {
|
|
return class extends React.Component<Omit<T, keyof ApplicationContext>> {
|
|
render() {
|
|
return (
|
|
<ApplicationContext.Consumer>
|
|
{authenticatedContext => <Component {...this.props as T} features={authenticatedContext} />}
|
|
</ApplicationContext.Consumer>
|
|
);
|
|
}
|
|
};
|
|
}
|