Skip to content

Classnames from props never get concatenated with resolved styleName. Replaced instead. #242

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

Closed
giorgosavgeris opened this issue Mar 20, 2019 · 5 comments

Comments

@giorgosavgeris
Copy link

We want to use HOCs which sent down some classnames like so:

The styleName in withWarning.js resolves from loader to a class name which will be passed down. Here assume the resolved className is withWarning__warning__er3432

// withWarning.js
import 'styles.scss'; // has inside a class .warning

export default Component => ({warning, ...props}) => {
  let styleNames = '';
  if (warning) {
    styleNames = 'warning';
  }
  return <Component {...props} styleName={styleNames}/>;
};

At prettyText.js the styleName resolves as prettyText__pretty__ty3342. At the same time the component received as a property className which previously resolved withWarning__warning__er3432. Instead of merging these two classes on the final outcome, only the resolved from styleName is being used and the className from props never gets concatenated unless someone would explicitly declare the className on JSX <div {...props} className={props.className} styleName='pretty' />.

// /prettyText.js
import withWarning from './withWarning';
import 'styles.scss'; // has inside a class .pretty

const Text = props => {
  return <div {...props} styleName='pretty' />;
};

export default withWarning(Text);

Ending up with something like so:

// index.js
import TextWithWarning from './text.js';

ReactDOM.render(<TextWithWarning warning>Error</TextWithWarning>);

// Expected: <div class='withWarning__warning__er3432 prettyText__pretty__ty3342'>Error</div>
// Got: <div class='prettyText__pretty__ty3342'>Error</div>
@giorgosavgeris
Copy link
Author

@gajus I think this is not an enhancement. It is a bug.

@gajus gajus added bug and removed enhancement labels Mar 20, 2019
@gajus
Copy link
Owner

gajus commented Mar 20, 2019

Is this not a duplicate of #44 ?

@giorgosavgeris
Copy link
Author

Maybe, I am not sure.

@giorgosavgeris
Copy link
Author

giorgosavgeris commented Mar 20, 2019

Issue #44 is open and unresolved from April 2017. Nobody will pay attention.

@gajus
Copy link
Owner

gajus commented Mar 20, 2019

Issue #44 is open and unresolved from April 2017. Nobody will pay attention.

Everyone is welcome to contribute, including you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants