How can I use javascript library such as moment.js in react native

Easy peasy! From the root of your project just run:

npm install moment --save

Then you can import it in your code:

import moment from 'moment';
var now = moment().format();

The restrictions would be anything that tries to “reach out” to the browser (which doesn’t exist in this context). That’s why there’s polyfills for things like XHR.

The official documentation has examples on how to use the moment library

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)