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
Some of the moment methods work in React Native and others don't. I suspect it has to do with listeners.
I can use moment for formatting:
moment(new Date()).format("YYYY-MM-DD hh:mm:ss")
But not for active formatting:
moment(new Date()).format("YYYY-MM-DD hh:mm:ss").fromNow()