I would like to use react-i18next with my react-redux connected component and am not sure how to go about it.
I've simplified my code to show an example of a connected component:
import React from 'react';
import {connect} from 'react-redux';
import {userSelectors} from "./userSelectors";
interface IConnectedProps {
activeUserName: string | undefined;
}
export class LandingPageComponent extends React.Component<IConnectedProps> {
public render(): JSX.Element {
return (
<React.Suspense fallback={<Spinner/>}>
<React.Fragment>
<div>
... a bunch of controls using translated text
</div>
<div>{activeUserName}</div>
</React.Fragment>
</React.Suspense> …
Run Code Online (Sandbox Code Playgroud) 如何调用具有先前状态的setState加上受控组件中的附加值?
典型的例子是:
Increment() {
this.setState((prevState, props) => ({counter: prevState.counter = props.step})
}
Run Code Online (Sandbox Code Playgroud)
但是,如何根据prevState和处理程序中的值更新状态.例如(我知道这个例子是错误的,因为你不能将值传递给setState回调):
HandleOnAddItem(evt, { value }) {
this.setState((prevState, props, value) -> ({items: value, ...prevState.items})
}
Run Code Online (Sandbox Code Playgroud) 我使用的是语义UI反应的Form.Input,它将输入分为两个div。
这意味着,
<Form.Input type='password' name='password' id='loginPassword'></Form.Input>
Run Code Online (Sandbox Code Playgroud)
呈现如下:
<div class='field'>
<div class='ui fluid action left icon input'>
<input type='password' name='password' id='loginPassword' ...>
<button ...>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想获取该<input/>
元素的引用,以便可以调用focus()。
如何获得对该<input/>
元素的引用?
顺便说一句,我正在使用redux,尽管我认为这并不重要
我同时具有文本输入和允许添加的下拉列表(均使用Form.xxx版本)。对于这两者,我想在右侧添加一个x图标,单击该图标将调用处理程序或清除输入值。
在语义用户界面反应中这可能吗?
谢谢