chandu0101 / sri

Build truly native cross platform (web,ios,android) apps using scalajs and react, react-native ,This project moved to new organization : https://github.com/scalajs-react-interface/sri#sri, new chat room : https://gitter.im/scalajs-react-interface/sri
Apache License 2.0
634 stars 35 forks source link

How to use sri 0.7 mobile with react-native-web? #60

Closed user471 closed 7 years ago

user471 commented 7 years ago

I used version 0.6

libraryDependencies += "com.github.chandu0101" %%% "sri-mobile" % "0.6.0"

and with

    <script type="text/javascript" src="https://unpkg.com/react@15.4.1/dist/react.js"></script>
    <script type="text/javascript" src="https://unpkg.com/react-native-web@0.0.64/dist/ReactNative.js">

I could open my app in browser and it worked. But with 0.7.1 I am not sure not to do it. There is an js error

exports is not defined
user471 commented 7 years ago

I also tried https://github.com/chandu0101/sri-mobile-template and has the same error

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
  </head>
  <body>
        <div id="root"></div>
    <script type="text/javascript" src="https://unpkg.com/react@15.4.1/dist/react.js"></script>
    <script type="text/javascript" src="https://unpkg.com/react-native-web@0.0.64/dist/ReactNative.js"></script>
    <script type="text/javascript" src="./assets/scalajs-output.js"></script>
    <script type="text/javascript">
      sri.mobile.template.MobileApp().main();
    </script>
  </body>
</html>
package sri.mobile.template

import sri.mobile.ReactNative
import sri.mobile.all._
import sri.mobile.template.router.AppRouter
import scala.scalajs.js.JSApp
import scala.scalajs.js.Dynamic.{literal => json}
import org.scalajs.dom

object MobileApp extends JSApp {

  def main() = {

    val root = createReactNativeRoot(
      AppRouter.router
    )
    ReactNative.AppRegistry.registerComponent("SriMobileTemplate", () => root)
    ReactNative.AppRegistry.runApplication("SriMobileTemplate", json(rootTag = dom.document.getElementById("root")))
  }
}
chandu0101 commented 7 years ago

if you're using only for web development nothing changed in 0.7.

as i said earlier sri will not work with global.React anymore , you must use npm .

user471 commented 7 years ago

if you're using only for web development nothing changed in 0.7.

I want to create mobile app and use same code to run it in browser with https://github.com/necolas/react-native-web It was possible with 0.6

as i said earlier sri will not work with global.React anymore , you must use npm .

Is there any description how sri works with React in 0.7?

chandu0101 commented 7 years ago

I want to create mobile app and use same code to run it in browser with https://github.com/necolas/react-native-web

then don't worry about updating to 0.7 now

Is there any description how sri works with React in 0.7?

sorry no particular doc other than working https://github.com/chandu0101/sri#templates . wish i had more time ;)