小编vbv*_*bvx的帖子

使用connect时使用redux-thunk键入错误

我正在使用redux和redux-thunk与typescript.我试图通过connect()注入一个组件,一个简单的thunk动作创建者,使用mapDispatchToProps.

操作

export enum TestActionTypes {
  THUNK_ACTION = "THUNK_ACTION"
}

export interface ThunkAction {
  type: TestActionTypes.THUNK_ACTION;
}

export type TestAction = ThunkAction;
Run Code Online (Sandbox Code Playgroud)

动作创作者

export function thunkActionCreator() {
  return function(dispatch: Dispatch<any>) {
    dispatch({ type: TestAction.THUNK_ACTION });
  };
Run Code Online (Sandbox Code Playgroud)

连接组件

interface DemoScreenState {}

interface OwnProps {}

interface StateProps {}

interface DispatchProps {
  testThunk: () => void;
}

type DemoScreenProps = StateProps & DispatchProps & OwnProps;

class DemoScreen extends React.Component<
  DemoScreenProps,
  DemoScreenState
> {
  constructor(props: DemoScreenProps) {
    super(props);
  }

  componentDidMount() {
    this.props.testThunk();
  }

  render() …
Run Code Online (Sandbox Code Playgroud)

typescript redux redux-thunk react-redux

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

Xcode 9 和 Xcode 服务器:用户未登录

在 High Sierra 和 Xcode9 之前,xcode 服务器是通过 server.app 进行管理的,并且工作正常。自从更新到 High Sierra 和 Xcode9 以来,我在使用 Xcode 服务器时一直遇到问题。由于机器人用户未登录,集成正在等待。 但是,当我检查 Xcode 机器人选项卡时,机器人用户被标记为已登录。

我已经尝试过的:

  1. 重新安装 xcode 并创建一个新的机器人帐户。
  2. 使用管理员用户进行集成
  3. 禁用屏幕保护程序和屏幕锁

解决方法:注销机器人配置文件,然后重新登录。

xcode-server

5
推荐指数
1
解决办法
702
查看次数

无法使用带有连接的引用的子方法

我想从子组件中调用一个方法,按照这里的建议从父组件中调用子方法

但是,当子组件用react-redux的connect包裹起来时,它不起作用,如下例所示:

子组件

interface OwnProps {
  style?: any;
}
interface ReduxStateProps {
  category: string;
}
interface DispatchProps {
  updateTimestamp: (timestamp: Date) => void;
}
type Props = ReduxStateProps & DispatchProps & OwnProps;

interface State {
  timestamp?: Date;
}

class ChildComponent extends React.Component<Props, State> {
  childMethod = () => {
    console.log("I am the child");
  };

  render(){
      <Text>Debug</Text>
  }
}

function mapStateToProps(state: any): ReduxStateProps {
  return {
    category: state.menu.category
  };
}

function mapDispatchToProps(dispatch: Dispatch<any>): DispatchProps {
  return {
    updateTimestamp: …
Run Code Online (Sandbox Code Playgroud)

react-native react-redux

4
推荐指数
1
解决办法
747
查看次数