lelandrichardson / react-primitives

Primitive React Interfaces Across Targets
MIT License
3.09k stars 108 forks source link

How does react-primitives detect which platform it's running on? #110

Closed tonyxiao closed 6 years ago

tonyxiao commented 6 years ago

And therefore which set of injection to use? Looking at the source code as well as published node module, it would seem that everything imports

require('./injection/react-native-web');
mathieudutour commented 6 years ago

it's not react-primitives which detect which platform it's running on, it's you build system. So the react-native bundler will take the .ios.js or .android.js files first, etc.

tonyxiao commented 6 years ago

@mathieudutour I understand how .ios and .android works - however how does the web part work?

tonyxiao commented 6 years ago

and sketch also

mathieudutour commented 6 years ago

on the web it's requiring index.js which is require('./injection/react-native-web'); and what you want.

For Sketch, skpm is looking for .sketch.js first.

In the end, it's just dependant of your bundler: what extension it prioritize.

tonyxiao commented 6 years ago

Got it - thank you!