jorgebucaran / classcat

Build a class attribute string quickly
MIT License
905 stars 22 forks source link

Bad class names order on server side rendering #10

Closed bertho-zero closed 6 years ago

bertho-zero commented 6 years ago

The order of my classes is different server side and client side, so I am forced to use classnames in the meantime.

jorgebucaran commented 6 years ago

@bertho-zero How can I reproduce this?

jorgebucaran commented 6 years ago

Also please post the code or similar code that you were using. I need to see how you were invoking classwrap and what arguments you passed to it.

bertho-zero commented 6 years ago

I had to use something like:

// kind === 'success' in my case

<button
  className={cw([ 'btn', 'btn-block', {
    [ `btn-${kind}` ]: !!kind
  }])}
>
  ...
</button>

On server I have btn btn-success btn-block and on client I have btn btn-block btn-success, or the other way round, I no longer have the example at hand.

jorgebucaran commented 6 years ago

@bertho-zero I tested the result on the server and on the client on CodePen and got the same result in both instances. This is my code.

console.log(
  cw([
    "btn",
    "btn-block",
    {
      [`btn-${kind}`]: !!kind
    }
  ])
) // => btn btn-block btn-success

Can you still reproduce the issue? And what Node.js version are / were you using on the server?

bertho-zero commented 6 years ago

No I did not succeed in reproducing it, certainly a change that was made only on one side.

jorgebucaran commented 6 years ago

@bertho-zero Thanks! FWIW I added a test for this and published 1.2.3 🎉