Coder Social home page Coder Social logo

expo-auto-navigation's Introduction

Auto Navigation

This project demonstrates automatic navigation built on top of react-navigation for the Expo ecosystem. The style is based on Next.js navigation.

Creating files in the pages/ folder creates new screens for a navigator. Each folder has a _config.json file which defines static properties for the navigator.

The metro.config.js adds a custom route /routes which returns a JSON object that contains file system info.

Usage

expo start --ios

Reload the app manually with r in the console, or shaking the device.

Code Loading

In the browser, code loading is often done exclusively with the <script /> tag:

  • <script /> tag is loaded.
  • src attribute is downloaded.
  • Results are passed to the JavaScript engine.

In native React, we don't have script tags, so we need an alternative approach to passing a string of JavaScript to the JS engine. Two ways that come to mind are eval() which is generally frowned upon in web, and the new Function(...) syntax. In this project I opt to code load by making a fetch request to download the JavaScript, then I pipe that code into the JS engine by invoking it in new Function():

const results = await new Function(`__GLOBAL_NAME__`, 'var foo = "bar"')(
  global
);

Now we just need to make error stack traces work correctly like this... Probably it'd make sense to split this functionality into a code loading library, maybe even make the new Function() part into a native method CodeLoading.loadStringAsync(...) for speed and security.

TODO

  • Transpile and host code using the Metro dev server
  • Export code using Metro config transforms
  • Source maps
  • React Refresh
  • Shallow module loading to improve chunk loading times
  • Store the chunks in the app file system for production and offline support.

Attribution

Parts of this project are based on Wormhole. The concept is based on Next.js FS based routing for web.

Some parts of the lazy loading reference "Kiki" my lazy sister <3

This project was made possible thanks to the funding and support of Expo.

expo-auto-navigation's People

Contributors

evanbacon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.