question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't fetch value from constant

See original GitHub issue

Example:

// Button.js
export const PRIMARY = Symbol();

export default const Button = (props, children) => {
  switch (props.type) {
    case PRIMARY:
      theme = 'Button--primary';
      break;
  }
  return (<button className={ theme } { ...props }>{ children }</button>)
}
export default Button;
// view code-block
import jsxToString from 'react-element-to-jsx-string';
import Button, {  PRIMARY } from 'Button.js';

console.log(jsxToString(<Button type={PRIMARY}>Primary</Button>))

My Problem is that the constant is not PRIMARY but Symbol():

<Button type={Symbol()}>
  Primary
</Button>

Is there a way to workaround that?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
schoenwaldnilscommented, Aug 3, 2017

ok, I got that. But still, now I see this:

<Button type={Symbol(PRIMARY)}>
  Primary
</Button>

but I expect this:

<Button type={PRIMARY}>
  Primary
</Button>
0reactions
armandabriccommented, Aug 10, 2017

I close this issue for now. If you have any comments on this do not hesitate I will reopen it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Get value of constant by name - Stack Overflow
To get field values or call members on static types using reflection you pass null as the instance reference.
Read more >
Don't Use Constants as Default Values in Entities
An issue while using constants as initial values for entity fields ... using an Object-Relational Mapper(ORM) to fetch persisted entities.
Read more >
mysql - Get a fixed value on a select
I just need the query to return this field with a fixed value; in this case a value in USD. How do I...
Read more >
Constant fetching value even after deletion. - Appian Community
I observed a strange behavior in Appian 16.2, A constant value is reflecting in one interface whereas I have deleted that constant permanently...
Read more >
Python Constants: Improve Your Code's Maintainability
If you need to update the constant's value, then you don't have to ... with a wildcard import will just get the greet()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found