重现步骤:
安装版本:
react 15.4.2
react-native 0.40.0
Run Code Online (Sandbox Code Playgroud)
创建一个新项目
react-native init reactNativeTest
Run Code Online (Sandbox Code Playgroud)
运行项目
1) Start Xcode
2) Open Project reactNativeTest
3) Run App
Run Code Online (Sandbox Code Playgroud)
当我在xcode中运行它时,我得到了弃用警告,语义问题和CoreFoundation错误.
看截图
当我启动react-native应用程序时,它总是启动,只要我将它连接到mac.
一旦我断开iphone,该应用程序大多挂起启动和崩溃,没有任何进一步的错误消息.但是,其他错误将显示在屏幕上(红色和黄色标记的错误).
当我双击homebutton时,奇怪的是,应用程序似乎处于启动状态,但我无法切换到它.
你如何调试最好的这种行为,并找到导致奇怪的启动行为的事情?
更新:
我发现了那些错误
2016-08-08 16:25:23.604 [warn][tid:main][RCTEventEmitter.m:54] Sending `websocketFailed` with no listeners registered.
2016-08-08 16:25:23.612113 PhoenixApp[525:64778] Sending `websocketFailed` with no listeners registered.
2016-08-08 16:25:23.742 [warn][tid:com.facebook.react.JavaScript] The regenerator/runtime module is deprecated; please import regenerator-runtime/runtime instead.
2016-08-08 16:25:23.741927 PhoenixApp[525:65027] The regenerator/runtime module is deprecated; please import regenerator-runtime/runtime instead.
2016-08-08 16:25:23.860 [info][tid:com.facebook.react.JavaScript] Running application "PhoenixApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2016-08-08 16:25:23.860251 PhoenixApp[525:65027] Running application "PhoenixApp" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, …Run Code Online (Sandbox Code Playgroud) 我试图以某种方式将这些连接到示例:
react-native-drawer with react-native-router-flux:遵循以下文档:https: //github.com/aksonov/react-native-router-flux/blob/master/docs/OTHER_INFO.md
如何将自定义抽屉放在文件中?
我总是得到错误,当试图像这样:
文件:components/Drawer.js
import Drawer from 'react-native-drawer';
import ControlPanel from './ControlPanel';
import {Actions, DefaultRenderer} from 'react-native-router-flux';
export default class extends Component {
render(){
const state = this.props.navigationState;
const children = state.children;
return (
<Drawer
ref="navigation"
open={state.open}
onOpen={()=>Actions.refresh({key:state.key, open: true})}
onClose={()=>Actions.refresh({key:state.key, open: false})}
type="displace"
content={<SideMenu />}
tapToClose={true}
openDrawerOffset={0.2}
panCloseMask={0.2}
negotiatePan={true}
tweenHandler={(ratio) => ({
main: { opacity:Math.max(0.54,1-ratio) }
})}>
<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />
</Drawer>
);
}
}
Run Code Online (Sandbox Code Playgroud)
文件:App.js
import Drawer from './components/Drawer'
Run Code Online (Sandbox Code Playgroud)
我收到这个错误. 在此输入图像描述
我有一个奇怪的行为。一旦我将套接字连接添加到 react/redux 系统,我的主要组件总是会被重新渲染,只要下一个 Action 被调度。
我也有这种行为,当我再次单击导航链接(发送相同的路由操作)时,组件也会重新渲染,即使我停留在同一页面上。
任何人都可以在这里帮助我走上正轨吗?非常感谢!
设置 react 0.15.x redux react-router v4 react-router-redux
容器的 app.jsx 和 App 结构:
class Root extends React.Component {
render() {
return (
<Provider store={store}>
<Router history={history}>
<Route path="/" component={RootContainer}>
<IndexRoute component={HomePage} />
<Route path="/start" component={StartPage} />
<Route path="*" component={NotFoundPage} />
</Route>
</Router>
</Provider>
);
}
}
Run Code Online (Sandbox Code Playgroud)
根容器
class RootContainer extends React.Component {
...
componentWillMount() {
this.connectToSocket();
this.joinChannel();
}
componentWillUnmount() {
this.socket.disconnect();
}
...
connectToSocket() {
this.socket = new Socket('/socket');
this.socket.connect();
this.socket.onOpen(() => {
this.props.connectState(); …Run Code Online (Sandbox Code Playgroud) react-native ×3
ios ×2
reactjs ×2
debugging ×1
iphone ×1
react-redux ×1
react-router ×1
redux ×1
router ×1
xcode ×1