我希望有更多关于 react-i18next 的 useSSR 的文档。在文档中,它声明要构建一个这样的组件......
import React from 'react';
import { useSSR } from 'react-i18next';
export function InitSSR({ initialI18nStore, initialLanguage }) {
useSSR(initialI18nStore, initialLanguage);
return <App />
}
Run Code Online (Sandbox Code Playgroud)
问题是它没有显示 initialI18nStore 道具的来源。我得到initialLanguage 将是类似'es'、'en'、'etc',但我只是不确定initialI18nStore 来自哪里。那是来自中间件还是 I18nextProvider?
不确定我是否需要添加另一个jshint库,或者我是否应该以不同的方式执行此操作.
我有一个文件(为了解释原因,我们称之为stuff-functions.js)导出这样的函数...
export function a() {
return 'stuff';
}
export function b() {
return 'more stuff';
}
export function c() {
return 'even more stuff';
}
Run Code Online (Sandbox Code Playgroud)
在另一个文件中,我正在导入该文件并通过参数调用该函数...
import * as stuffFunctions from './stuff-functions'
export default class someReactClass {
myFunc(functionToCall) {
return stuffFunctions[functionToCall]();
}
...
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但在控制台我得到一个eslint错误...
Unable to validate computed reference to imported namespace 'stuffFunctions'
Run Code Online (Sandbox Code Playgroud)
那么,我应该采取不同的方式或追捕某种允许这种情况的eslint库吗?
编辑...
我添加了这一行来阻止错误// eslint-disable-line
如果有更好的方法,我只是好奇.也许像...
import {a, b, c} from './stuff-functions';
export default class someReactClass {
myFunc(functionToCall) {
const myStuffFunctions = {
a: a,
b: …
Run Code Online (Sandbox Code Playgroud) 我认输了。我似乎无法弄清楚这一点。我已经设置了一个 firebase 应用程序,只是尝试对数据进行简单的请求,但它返回 null。我的数据库目前设置为公开,所以不应该有任何权限问题。我可以使用 npm 包成功进行身份验证,react-firebaseui/StyledFirebaseAuth
并取回用户信息,因此它在某种程度上可以正常工作,但我无法从数据库中获取数据。我已经多次浏览文档并尝试在此处搜索问题,但似乎找不到任何内容。我试图做到彻底。所以这基本上就是我所拥有的......
// The actual config in the code is copied directly from the firebase general settings page, so if it isn't right, it isn't right on their page.
const config = {
apiKey: "someKey",
authDomain: "myAppId.firebaseapp.com",
databaseURL: "https://myAppId.firebaseio.com",
projectId: "myAppId",
storageBucket: "myAppId.appspot.com",
messagingSenderId: "mySenderId"
};
const handleSnapshot = (snapshotVal) => {
console.log(snapshotVal);
// Using react hence the setState, but this and the console.log return null
this.setState({data: snapshotVal});
}
firebase.initializeApp(config);
database = firebase.database()
countriesRef …
Run Code Online (Sandbox Code Playgroud)