我对找到字符串的长度的解决方案感到困惑:
const getLength = ({length}) => length
我熟悉对象和数组的解构,但是找不到关于字符串解构(?)或返回长度的任何信息。在函数参数中添加花括号的概念对我来说也是陌生的。
我正在尝试在我的 React/Firebase 应用程序中使用 Google 登录用户。我已经按照 youtube 上的教程(https://www.youtube.com/watch?v=umr9eNbx3ag)进行操作,但结果有所不同。当我单击“登录”按钮时,我会被重定向到 Google,选择一个帐户,然后被重定向到我的网站。
看来我的“if”语句从未运行,auth.currentUser也从未评估为 true。
这是我的 Firebase 文件
firebase.initializeApp(firebaseConfig)
export const firestore = firebase.firestore()
export const auth = firebase.auth()
export const provider = new firebase.auth.GoogleAuthProvider()
export const signInWithGoogle = () => auth.signInWithRedirect(provider)
export const signOut = () => auth.signOut()
export default firebase
Run Code Online (Sandbox Code Playgroud)
这是我的登录组件
import { auth, signInWithGoogle, signOut } from '../../Firebase/Firebase'
const LoginOrRegister = () => {
const { username, setUsername, idToken, setIdToken } = useContext(Context)
useEffect(() => {
auth.onAuthStateChanged(async nextUser …Run Code Online (Sandbox Code Playgroud) 该数组由这样的对象组成
[
{
name: 'john',
date: '21-07-2020',
car: 'bmw'
},
{
name: 'fred',
date: '14-10-2020',
car: 'tesla'
}
]
Run Code Online (Sandbox Code Playgroud)
我试图使用 Moment 的isBefore函数按升序对其进行排序,但使用 Moment 库它不起作用:
array.sort((a, b) => moment(a.date, 'DD-MM-YYYY').isBefore(moment(b.date, 'DD-MM-YYYY')))
Run Code Online (Sandbox Code Playgroud) 我想更新completedFirestore 中数组中对象的属性,但我不知道如何访问数组中的特定元素。图像将显示结构。
我已经走到这一步了,但不知道如何选择,例如数组中的第 1 项。我正在考虑使用它的 ID(它有一个 id 属性),但不知道如何到达那里。
const businessRef = db.collection('approvedBusinesses').doc(businessId)
try {
businessRef.update({
[`bookings.${currentDate} ????? `]: true // what to add after currentDate?
})
Run Code Online (Sandbox Code Playgroud)
顺便说一下,这就是数组的创建方式(以及如何将其他对象推送到数组)
const bookingObj = {
carro: 'PASSA_CARRO',
completed: false,
userId: userObject.uid,
}
businessRef.update({
[`bookings.${currentDate}`]: firebase.firestore.FieldValue.arrayUnion(bookingObj),
})
Run Code Online (Sandbox Code Playgroud) 我正在尝试预览我的 firebase 网站并使用以下命令共享:
firebase hosting:channel:deploy "testing_changes"
Run Code Online (Sandbox Code Playgroud)
但我不断得到 Error: hosting:channel:deploy is not a Firebase command
我也试过不传递字符串而只传递单词,但我得到了同样的错误。我很确定我在根目录中。
之前发生过此错误并已找到解决方案(https://github.com/facebook/create-react-app/issues/8465,运行 npm install create-react-app 时出现错误 404)。他们似乎都不适合我。还有其他想法吗?
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/creat-react-app - Not found
npm ERR! 404
npm ERR! 404 'creat-react-app@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! …Run Code Online (Sandbox Code Playgroud) 我无法在 Formik 自己的文档或互联网上找到如何实现单选按钮的示例。我正在尝试将以下内容转换为单选按钮
<Form>
<Field name="prices" as="select">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</Field>
</Form>
Run Code Online (Sandbox Code Playgroud)
我尝试将其更改as为radio或删除它并type改为使用 with radio,但它也不起作用
我正在学习有关 AWS Beanstalk 的课程,但该课程可能已过时。在 IAM 管理控制台中,添加了一个用户,并且直接附加的现有策略之一是AWSElasticBeanstalkFullAccess,我自己过滤策略时找不到。
这是改名了吗?我怎样才能找到它或等价物?