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

后端 未结 5 2071
臣服心动
臣服心动 2021-02-06 20:13

What is the recommended way to use native javascript libraries in react native? Are there any specific restrictions?

5条回答
  •  耶瑟儿~
    2021-02-06 20:45

    It looks like as of right now, some npm modules are not compatible with the packager. Haven't really dug into why yet, but what I've been resorting to doing is having a vendor folder and copying over the web version but at the top specifically putting

    /** * @providesModule moment */

    And at the bottom changing it up to:

    module.exports = moment;

    Not sure if this is the correct way yet, but the packaging is still pretty new to everyone.

提交回复
热议问题