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

can't load styled material-ui view #245

Closed
Spongman opened this issue May 15, 2020 · 1 comment
Closed

can't load styled material-ui view #245

Spongman opened this issue May 15, 2020 · 1 comment
Labels

Comments

@Spongman
Copy link

i'm getting an error in dotnetify-react.js (in loadReactView()):

dotnetify-react.js:3766 [AppLayout] failed to load view '[object Object]' because it's not a valid React element.

the component is defined as a styled material-ui component somewhat like this:

const styles = (theme: Theme) => createStyles({
    ...
});
interface Props extends WithStyles<typeof styles> {
    ...
};
class MyComponentClass extends React.Component<Props> {
    ...
};
export const MyComponent = withStyles(styles)(MyComponentClass);

the check that's failing is:

if (typeof iComponent !== 'function' && ((typeof iComponent === 'undefined' ? 'undefined' : _typeof(iComponent)) !== 'object' || iComponent.name == null)) {

typeof iComponent is "object"

@dsuryd dsuryd added the bug label May 16, 2020
@dsuryd
Copy link
Owner

dsuryd commented May 16, 2020

The check incorrectly expects a React component to always have a name property. For now, the workaround is to add it manually:

export const MyComponent = Object.assign(withStyles(styles)(MyComponentClass), { name: '' });

@dsuryd dsuryd closed this as completed in 44167e7 May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants