Giter Club home page Giter Club logo

Comments (8)

ashleydw avatar ashleydw commented on July 24, 2024

Also getting this, although it was working in 1.1.1 but #6 seems to have broken it.

@smartdemocracy can you shed some light on this?

from react-native-device-uuid.

ashleydw avatar ashleydw commented on July 24, 2024

I had to update my JavaScript code from the code shown in the readme to a callback:

DeviceUUID.getUUID((errors, result) => {
   ...
})

I prefer the promise, so I re-wrote it

return new Promise((resolve, reject) => {
   DeviceUUID.getUUID((errors, result) => {
      if (errors)
         return reject(errors);
      else
         return resolve(result);
   })
});

from react-native-device-uuid.

antoniopresto avatar antoniopresto commented on July 24, 2024

I tested again, still working here.You may need to check the values before accessing. is working well with setState:

//[...]
class App extends Component {
    constructor(props) {
        super(props);
        this.state = {
            uuid: ''
        }
    }

    componentDidMount() {
        var DeviceUUID = require("react-native-device-uuid");
        DeviceUUID.getUUID().then((uuid) => {
            this.setState({uuid});
        });
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={{backgroundColor:'white', paddingTop: 77}}>
                    {this.state.uuid || 'NO UUID'}
                </Text>
            </View>
        );
    }
}

image

from react-native-device-uuid.

ashleydw avatar ashleydw commented on July 24, 2024

I found my error; NativeModules are required from react-native not require('NativeModules'). I modified our version for this:

https://github.com/fixdio/react-native-device-uuid/blob/master/DeviceUUID.ios.js

Documentation from react native: facebook/react-native@e5ba0f3#comments

from react-native-device-uuid.

dorthwein avatar dorthwein commented on July 24, 2024

I had the same issue and using @ashleydw seemed to resolve it - thanks!

from react-native-device-uuid.

lazywei avatar lazywei commented on July 24, 2024

awesome!
@ashleydw would you mind send me a pull request for your modification?
Thanks 👍

from react-native-device-uuid.

lazywei avatar lazywei commented on July 24, 2024

I assume this issue has been solved. Please feel free to reopen it if not 😄
Thanks for all you guys' efforts.

from react-native-device-uuid.

quantuminformation avatar quantuminformation commented on July 24, 2024

I no longer get any errors, thanks.

Also thanks for the doc, very helpful

image

from react-native-device-uuid.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.