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.

Text element does not accept numbers in properties

See original GitHub issue

Thats work:

  const value = '50';
  <Text>{value}</Text>

But this does not:

  const value = 50;
  <Text>{value}</Text>

This also does not work:

  const x = 10;
  <Text x={x}>some text</Text>

I forked magicismight/react-native-svg-example and show bugs in the expose-text-bug branch: https://github.com/vovkasm/react-native-svg-example/tree/expose-text-bug

To show:

  1. git clone https://github.com/vovkasm/react-native-svg-example.git
  2. git checkout expose-text-bug
  3. npm install
  4. npm start
  5. react-native run-ios

I did not test android, only iOS.

BTW. Internal example in Example folder completely broken and requires bunch of exponent staff. In current stage it cannot be used for testing. (((

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
magicismightcommented, Jan 16, 2017

Fix is shipped in 5.1.3

1reaction
magicismightcommented, Jan 16, 2017

Thanks for reporting this. I’ll fix this soon. I had tested the number text by using this, and this works fine.

            <Text
                x="50"
                y="9"
                fill="red"
                textAnchor="middle"
            >111</Text>

But I haven’t expected this would go wrong:

      const n = 111;
      return <Svg
            height="30"
            width="100"
        >
            <Text
                x="50"
                y="9"
                fill="red"
                textAnchor="middle"
            >{n}</Text>
        </Svg>;
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

<input type="number"> - HTML: HyperText Markup Language
<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Read more >
How to make HTML input tag only accept numerical values?
You can use the <input> tag with attribute type='number'. This input field allows only numerical values. You can also specify the minimum value ......
Read more >
Restrict an HTML input text box to allow only numeric values
This post will discuss how to restrict an HTML input text box to allow only numeric values... The standard solution to restrict a...
Read more >
Textbox - LongRange
An integer that specifies the maximum number of characters the textbox would accept. A special value of 0 indicates that no limit would...
Read more >
HTML Input Attributes - W3Schools
The size attribute works with the following input types: text, search, tel, url, email, and password. · When a maxlength is set, the...
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