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

Proposal: Support for symbols #146

Open
jshthornton opened this issue Jun 6, 2017 · 0 comments
Open

Proposal: Support for symbols #146

jshthornton opened this issue Jun 6, 2017 · 0 comments

Comments

@jshthornton
Copy link

jshthornton commented Jun 6, 2017

Symbols offer nice features such as ensuring that enums values are actually distinct across different enums.

It would be nice to be able to supply symbols as modifiers so that multiple modifiers of different enums were supported.

Take this example.

const MyEnum = {
  A: 'A',
  B: 'B',
  C: 'C',
};

const YourEnum = {
  A: 'A',
  B: 'B',
  C: 'C',
};

const styles = reactCSS({
  default: {
    root: {
      width: 10,
    }
  },
  [MyEnum.A]: {
    root: {
        width: 20,
    }
  },

  [YourEnum.A]: {
    root: {
      height: 10,
    }
   }
}, {
  [MyEnum.A]: x === MyEnum.A,
  [YourEnum.A]: y === YourEnum.A,
});

This would cause a conflict in keys. To solve this problem enums are often written using symbols.

const MyEnum = {
  A: Symbol('A'),
  B: Symbol('B'),
  C: Symbol('C'),
};

const YourEnum = {
  A: Symbol('A'),
  B: Symbol('B'),
  C: Symbol('C'),
};

The current for own, and to string of key-value doesn't permit symbols to be used.

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

1 participant