我目前在 React-Native 中有一个组件,我正在使用 NativeBase 预设组件。
import React, { Component } from 'react';
import { FlatList, ActivityIndicator, StyleSheet } from 'react-native';
import { Container, Header, Content, ListItem, Text, Input, Item, Button, Left, Right } from 'native-base';
export default class OrderDetail extends Component {
constructor(props){
super(props);
this.state= { isLoading: true }
}
componentDidMount() {
return fetch('https://facebook.github.io/react-native/movies.json')
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson.movies,
}, function() {
});
})
.catch((error) => {
console.error(error);
});
}
render() {
return ( …Run Code Online (Sandbox Code Playgroud) 我知道以前曾经问过这个问题,但根据我的情况,我找不到一个有效的答案.
目前我有两个型号.App\JobStatus App\Customer
在模型App\JobStatus我有这个:
public function customer()
{
return $this->belongsTo('App\Customer');
}
Run Code Online (Sandbox Code Playgroud)
在模型App\Customer我有这个:
public function jobs()
{
return $this->hasMany('App\JobStatus', 'customer_id');
}
Run Code Online (Sandbox Code Playgroud)
'customer_id'是外键.然后我尝试从我的控制器中的Jobstatus访问客户,如下所示:
$testMePlease = JobStatus::first()->where('qb', '=', 1);
$testMePlease->customer;
Run Code Online (Sandbox Code Playgroud)
我曾尝试过这个.把它放在foreach循环中.我也试过$ testMePlease-> customer-> customer_name.Customer_name是表中的一列,我得到了同样的错误:"Undefined property:Illuminate\Database\Eloquent\Builder :: $ customer"
我有什么想法我做错了吗?
我目前在我的 React 项目中有一个提供者和上下文设置。上下文扩展了firebase。成分:
import React from 'react';
const FirebaseContext = React.createContext(null);
export const withFirebase = Component => props => (
<FirebaseContext.Consumer>
{firebase => <Component {...props} firebase={firebase} />}
</FirebaseContext.Consumer>
)
export default FirebaseContext;
Run Code Online (Sandbox Code Playgroud)
使用类组件,我可以像这样访问 firebase:
import { withFirebase } from "../components/Firebase";
Run Code Online (Sandbox Code Playgroud)
我的出口是这样的:
export default withFirebase(Admin);
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我可以在我的组件(管理员)中访问this.props.firebase和执行。
我的问题是我有一个功能组件,它是 Admin 的孩子的孩子。管理 -> 子组件 -> 子组件(这是一个)
在这里,我使用与上面相同的导入 withFirebase 并将导出包装在 withFirebase()
const MinistriesAdminForm = props => {
const [ministries, setMinistries ] = useState([]);
useEffect(() => {
this.props.firebase.getMinistries(this.state.currentOrganization).on("value", data => {
const ministriesObject = …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试循环运行一个函数。
无法弄清楚,这是我尝试过的:
do {
queryLastCursor(lastCursor).then(lastCursorResults => {
if (lastCursorResults.hasNext = false) {
hasNextPage = false;
}
console.log(hasNextPage);
})
} while (hasNextPage);
Run Code Online (Sandbox Code Playgroud)
queryLastCursor是一种调用 API 的方法。当它返回数据时,它的值将是hasNext如果它返回 false 那么我想设置hasNextPage为false. 预期的行为是它一次又一次地运行该函数,直到我们得到结果hasNext = false。知道我做错了什么吗?
eloquent ×1
javascript ×1
laravel ×1
laravel-5 ×1
native-base ×1
php ×1
react-hooks ×1
react-native ×1
reactjs ×1