React Nativeでチャット機能を実装したいと思っています。
後ろはFirebaseを使っています。
Airbnbのようにホストとゲストのようなユーザーがいる仕組み上で、ホストが出している家の情報のスクリーンからメッセージを送ることができる機能を想定しています。
Qiitaの記事を参考に設計を進めてみたのですが、2点の問題が生じました。
(1) ReferenceError: room is not defined
このアクションで作成したroomのidをthen後で使いたいが、使えない・・・
(2) 下記で
userId: currentUser.uid,
としているところを
currentUser.uid: true,
としたいが、エラーが出てしまってできない。
/** * Builds an action to create a message */ export const roomCreate = ({ host, navigation }) => { const { currentUser } = firebase.auth(); return (dispatch) => { firebase.database().ref(`/rooms/`) .push({ users: { userId: currentUser.uid, userId: host.uid } }) .then(() => { firebase.database().ref(`/users/${currentUser.uid}/rooms/${host.uid}`) .update({ roomId: room.uid }); firebase.database().ref(`/users/${host.uid}/rooms/${currentUser.uid}`) .update({ roomId: room.uid }); }); } }
すみませんが、どうかお助けくださいませ。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/14 15:15
2018/04/18 07:43
2018/04/18 17:40