Nick Allen
Nick Allen

Reputation: 1873

How does React Native require(moduleName) work?

I saw code like var Animated = require('Animated') in react-native source code. But how can this be resolved without a path ?
My guess is that will be preprocessed by the packager by something like registering and I would like to do this in my own project. But there seems to be no document for react-native's packager , and I can't find the source code where this "registering" happen.

Upvotes: 2

Views: 411

Answers (2)

Nick Allen
Nick Allen

Reputation: 1873

I think I find it! Just add @providesModule moduleName in the file's comment in the header , look into issue 896 for detail.

Upvotes: 2

李振纲
李振纲

Reputation: 382

import {
  Animated,
  View,
  Text,
} from 'react-native';

i can't catch what you said.but i post the above snippet how i used.

Upvotes: 0

Related Questions