小编mde*_*eus的帖子

How do I use react-i18next with a connected component

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)

reactjs react-redux react-i18next

15
推荐指数
2
解决办法
967
查看次数

如何调用具有先前状态的setState以及redux连接受控组件中的附加值?

如何调用具有先前状态的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)

reactjs react-redux

8
推荐指数
1
解决办法
1万
查看次数

需要从语义UI反应的Form.Input到&lt;input&gt;的引用-在React中被div包围

我使用的是语义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()。

  1. 使用ref ='myRef'时,我的参考设置为组件
  2. ReactDOM.findDOMNode返回一个DOM引用,但是该引用设置为外部div(带有class ='field')。

如何获得对该<input/>元素的引用?

顺便说一句,我正在使用redux,尽管我认为这并不重要

javascript reactjs semantic-ui-react

4
推荐指数
2
解决办法
3054
查看次数

在Semantic-UI-React中,是否可以将x图标添加到文本输入或下拉菜单中,以在单击时清除文本?

我同时具有文本输入和允许添加的下拉列表(均使用Form.xxx版本)。对于这两者,我想在右侧添加一个x图标,单击该图标将调用处理程序或清除输入值。

在语义用户界面反应中这可能吗?

谢谢

semantic-ui-react

3
推荐指数
1
解决办法
4157
查看次数