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

Multiple withStyles only rendering the first #37

Closed
Ehesp opened this issue Apr 18, 2016 · 5 comments
Closed

Multiple withStyles only rendering the first #37

Ehesp opened this issue Apr 18, 2016 · 5 comments

Comments

@Ehesp
Copy link

Ehesp commented Apr 18, 2016

I asked this on Gitter originally, but I'm struggling to get the following to work (example):

import appStyles from './App.scss`;
import otherStyles from '../OtherComponent/otherStyles.scss';

...

export default withStyles(App, appStyles, otherStyles);

This doesn't throw any errors, and both the styles are within the styles array, only the appStyles are loaded in.

Is this the correct way of going about this?

@Ehesp
Copy link
Author

Ehesp commented Apr 18, 2016

Note: After upgrading to version 1.0.0, with a different syntax this problem still occurs.

@frenzzy
Copy link
Member

frenzzy commented Apr 18, 2016

Your context insertCss function should handle all style arguments rather than just one, for example:

// client.js
const context = {
  insertCss(...styles) { styles.forEach(style => style._insertCss()); },
};
// server.js
const css = [];
const context = {
  insertCss(...styles) { styles.forEach(style => css.push(style._getCss())); },
};

@koistya
Copy link
Member

koistya commented Apr 18, 2016

I guess, we need to create <StylesContext> (or <StylesProvider>) React component, that can be used to set insertCss context variable..

@Ehesp
Copy link
Author

Ehesp commented Apr 18, 2016

Right makes sense, we were only taking the first item rather than the array of items. Cheers.

@Ehesp Ehesp closed this as completed Apr 18, 2016
@adrianricardo
Copy link

@Ehesp what was the resolution?

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

No branches or pull requests

4 participants