我的根 Firebase 配置代码位于名为 FirebaseConfig.js 的文件中。我希望能够从整个应用程序的容器组件访问在那里配置的数据,以便配置特定于所述子组件的子引用。
FirebaseConfig.js
import React, { Component } from 'react';
import * as firebase from 'firebase';
class FirebaseConfig extends Component {
render() {
const config = {...
};
firebase.initializeApp(config);
// INIT DB REFERENCE
const db = firebase.database();
const dbRef = db.ref();
// INIT STORAGE REFERENCE
const storage = firebase.storage();
const storageRef = storage.ref();
console.log("FB INIT'D with STORAGE REF: " + storageRef);
return FirebaseConfig;
}
}
export default FirebaseConfig;
Run Code Online (Sandbox Code Playgroud)
文件结构
src
|__App.js
|__index.js
|__FirebaseConfig.js
|__ /Home
|__ Home.js …Run Code Online (Sandbox Code Playgroud) 使用XCode 7.1,OS X 10.10.5
我正在实现ENSideMenu库,并且我在库中使用两个方法遇到此错误:
if (NSClassFromString("UIVisualEffectView") != nil) {
// Add blur view
var visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView
visualEffectView.frame = sideMenuContainerView.bounds
visualEffectView.autoresizingMask = .FlexibleHeight | .FlexibleWidth // error points to .FlexibleHeight
sideMenuContainerView.addSubview(visualEffectView)
}
else {
// TODO: add blur for ios 7
}
}
public convenience init(sourceView: UIView, menuViewController: UIViewController, menuPosition: ENSideMenuPosition) {
self.init(sourceView: sourceView, menuPosition: menuPosition)
self.menuViewController = menuViewController
self.menuViewController.view.frame = sideMenuContainerView.bounds
self.menuViewController.view.autoresizingMask = .FlexibleHeight | .FlexibleWidth // error points to .FlexibleHeight
sideMenuContainerView.addSubview(self.menuViewController.view)
}
Run Code Online (Sandbox Code Playgroud)
两者都指向 …
我正试图把烧瓶挂到mongoengine上.所有模块似乎都已成功安装.这是我的导入,而ln 4是错误源自的地方:
import os
from flask import Flask, render_template, send_from_directory
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
File "app.py", line 4, in <module>
from flask.ext.mongoengine import MongoEngine
File "/Users/name/Desktop/venv3/lib/python2.7/site-packages/flask/exthook.py" line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.mongoengine
Run Code Online (Sandbox Code Playgroud)
我可能做错了什么或者如何获得flask.ext.mongoengine的任何想法?
我在单独的文件夹中有两个reducer,用于与此类似的结构中的单独组件:
index.js
/componentOne
|_ componentOne.js
|_ componentOneActionCreator.js
|_ componentOneReducer.js
/componentTwo
|_ componentTwo.js
|_ componentTwoActionCreator.js
|_ componentTwoReducer.js
Run Code Online (Sandbox Code Playgroud)
这些Reducers中的每一个都在应用程序中单独工作 - 当我createStore进入index.js(他们import进入)时 - 但如果我尝试使用它们combineReducers(),它们的功能都不起作用(但不会打破UI).我认为这与州有关 - 更多代码供以下参考:
index.js
const rootReducer = combineReducers({
componentOneReducer,
componentTwoReducer
});
let store = createStore(rootReducer, applyMiddleware(thunk))
Run Code Online (Sandbox Code Playgroud)
componentOneReducer
export default(state = {}, payload) => {
let newState = JSON.parse(JSON.stringify(state));
switch (payload.type) {
case 'REQUEST_DATA':
newState.isLoading = true;
return newState;
case 'RECEIVE_DATA':
newState.isLoading = false;
newState.pageData = payload.payload;
newState.pageName = payload.payload.pageName;
return newState
default: …Run Code Online (Sandbox Code Playgroud) 我有以下路线:
<Switch>
<Route path='/:profileType/:profileId' component={Profile}/>
<Route path='/about/:aboutThing' component={AboutThing}/>
</Switch>
Run Code Online (Sandbox Code Playgroud)
当我尝试去/about/:aboutThing- 它被认为是一条{Profile}路线.这是有道理的,因为技术上:profileType可以是任何字符串,因此任何嵌套路由都将被识别为Profile.
我想知道是否可以在{AboutThing}不改变路线的情况下进行渲染.从技术上讲,/about应该是该路线的保留字.我试过做:
<Route exact path='/about/:aboutThing' component={AboutThing}/>
但这也不起作用.尝试不必在该路径中添加额外的字符串以使其工作.有什么想法/想法吗?
javascript ×3
reactjs ×3
firebase ×1
ios ×1
mongodb ×1
mongoengine ×1
python-2.7 ×1
react-redux ×1
react-router ×1
redux ×1
redux-thunk ×1
swift ×1
swift2 ×1