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.

React-Native Support

See original GitHub issue

Will this work with react native?

I tried to install and got a Transform Error from Babel:

TransformError: /Users/XXX/node_modules/react-number-format/lib/number_format.js: 
[BABEL] /Users/XXX/node_modules/react-number-format/lib/number_format.js: 
Unknown option: /Users/XXX/node_modules/react/react.js.Children. 
Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options. (While processing preset: "/Users/XXX/node_modules/react/react.js")

RCTFatal + 124
-[RCTBatchedBridge stopLoadingWithError:] + 1124
__25-[RCTBatchedBridge start]_block_invoke_2 + 76
<redacted> + 24
<redacted> + 16
_dispatch_main_queue_callback_4CF + 1000
<redacted> + 12
<redacted> + 1660
CFRunLoopRunSpecific + 444
GSEventRunModal + 180
<redacted> + 684
UIApplicationMain + 208
main + 124
<redacted> + 4

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:9
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

158reactions
questionablequestioncommented, Jun 6, 2018

To make this work with React Native all you have to do is to provide custom renderText method:

import NumberFormat from 'react-number-format';

<NumberFormat
    value={2456981}
    displayType={'text'}
    thousandSeparator={true}
    prefix={'$'}
    renderText={value => <Text>{value}</Text>} <--- This
/> 
78reactions
DrJidcommented, Jun 29, 2018

Just to add to @questionablequestion response, to get this working for an asYouType formatter, you can render a TextInput

              <NumberFormat
                value={amount}
                displayType={'text'}
                thousandSeparator={true}
                prefix={'$ '}
                renderText={value => (
                  <TextInput
                    underlineColorAndroid="transparent"
                    style={styles.input}
                    onChangeText={this.handleChange}
                    value={value}
                    keyboardType="numeric"
                  />
                )}
              />

where handleChange basically just changes state for your controlled component. Ex

 handleChange = amount => {
    this.setState({ amount })
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Where to get help - React Native
If you need help with your React Native app, the right place to ...
Read more >
Where To Get Support - React
Where To Get Support. React has a community of millions of developers. On this page we've listed some React-related communities that you can...
Read more >
React Native Experts to Help, Mentor, Review Code & More
Find a freelance React Native expert for help with reviewing code, mentorship, tutoring, and other React Native help you might need.
Read more >
React Native - Wikipedia
React Native is an open-source UI software framework created by Meta Platforms, Inc. It is used to develop applications for Android, Android TV,...
Read more >
React Native Support - Flipper
React Native Support ... Meta's React Native and Developer Tooling teams work in close collaboration to ensure Flipper offers top-notch out-of-the-box value for ......
Read more >

github_iconTop Related Medium Post

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