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

rendertostaticmarkup not working with muitheme #4143

Closed
mikeatm opened this issue May 2, 2016 · 3 comments
Closed

rendertostaticmarkup not working with muitheme #4143

mikeatm opened this issue May 2, 2016 · 3 comments
Labels
customization: theme Centered around the theming features v0.x

Comments

@mikeatm
Copy link

mikeatm commented May 2, 2016

  • Material-UI: v0.15.0-beta.2
  • React: 1.3.6
  • Browser: Chrome 49.0.2623.87

this snipped that iv been using ReactDOM.renderToStaticMarkup now throws an error

    let container = renderToStaticMarkup(
                   <MuiThemeProvider muiTheme={getMuiTheme()}>
                    <RaisedButton   label={this.options.state.label} icon={icon} />
                   </MuiThemeProvider>
                   );

this is the error on muitheme:

warning.js:44 Warning: Failed Context Types: Required context `muiTheme` was not specified in `RaisedButton`.
RaisedButton.js:236 Uncaught TypeError: Cannot read property 'prepareStyles' of undefined

Iv recently moved form 14.X to the newest tag, and the rest of the app works after adjusting the necessary import paths as well as adding a default muitheme, how would we go about using muiTheme with the renderToStaticMarkup? is there something else here we need to add? as my code looks like its providing the
neccessary context.

i tried to change it to this and it did not work either (providing muiTheme to the button directly):

    let container = renderToStaticMarkup(
                   <MuiThemeProvider muiTheme={getMuiTheme()}>
                    <RaisedButton muiTheme={getMuiTheme()}  label={this.options.state.label} icon={icon} />
                   </MuiThemeProvider>
                   );
@mikeatm mikeatm closed this as completed May 3, 2016
@mikeatm
Copy link
Author

mikeatm commented May 3, 2016

Turns out there was another similar problem that was unresolved, but only this had been fixed, fixing both resolved it.

@tangweikun
Copy link

Did you solved this problem now?I have the same problem, I don't know how to deal with it

@mikeatm
Copy link
Author

mikeatm commented Jun 3, 2016

Yes, i had not provided the theme to all instances where i had been calling the function, leading me to mistakenly fault the function, it works, so just use it as usual:

let container = renderToStaticMarkup( <MuiThemeProvider muiTheme={getMuiTheme()}> <div> <RaisedButton icon={icon} /> </div> </MuiThemeProvider> );

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added v0.x customization: theme Centered around the theming features and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features v0.x
Projects
None yet
Development

No branches or pull requests

4 participants