taofed / react-web

A framework for building web apps with React Native compatible API.
Other
3.36k stars 449 forks source link

react-navigation支持吗 #262

Open jjiangkm opened 7 years ago

jjiangkm commented 7 years ago

新版本的reactnative推荐使用reactnavigation,打开后提示 image

cpunion commented 7 years ago

打下面的补丁以后可以用:

import {StyleSheet} from 'react-web'
import { Linking } from 'react-navigation/lib/PlatformHelpers'

Linking.getInitialURL = () => {
  return new Promise(resolve => {
    resolve('')
  })
}

StyleSheet.absoluteFill = StyleSheet.create({
  position: 'absolute',
  left: 0,
  right: 0,
  top: 0,
  bottom: 0
})

注意 import 时一定加上 .js 后缀,否则会导入 react-navigation.web.js,这个没有实现完整:

import {
  StackNavigator,
  TabNavigator
} from 'react-navigation/lib/react-navigation.js'
xiamingyu commented 7 years ago

打补丁怎么打

cpunion commented 7 years ago

index.ios.js:

import './patch.js'
require('./src') // 用 require 保证在 import patch 之后运行

patch.js

import {StyleSheet} from 'react-web'
import { Linking } from 'react-navigation/lib/PlatformHelpers'

Linking.getInitialURL = () => {
  return new Promise(resolve => {
    resolve('')
  })
}

StyleSheet.absoluteFill = StyleSheet.create({
  position: 'absolute',
  left: 0,
  right: 0,
  top: 0,
  bottom: 0
})

src/index.js

import { AppRegistry } from 'react-native'
import {
  StackNavigator,
  TabNavigator
} from 'react-navigation/lib/react-navigation.js'

// 你的 react native 程序代码...

AppRegistry.registerComponent('...', () => ...)
xiamingyu commented 7 years ago

image 目测只有这行代码有用

sandofsuro commented 6 years ago

我打了补丁没有用啊

FattySpring commented 6 years ago

我也不能用