小编Yog*_*Yog的帖子

使用 Typescript 在 React 中重定向

我正在使用 Typescript 进行 React。“重定向”似乎对我不起作用。我不知道是什么问题。

import * as React from "react"
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
import store from "./ToDoStore"
import { Redirect} from "react-router-dom";
export class AddTodo extends React.Component {


refs: {
    name: (HTMLInputElement);
    description: (HTMLInputElement);
}

addTodo() {
    store.addTodo({ name: this.refs.name.value, description: this.refs.description.value })
    alert("Task added successfully");

 <Redirect to="/home" push/>
}

render() {

    return (
        <div id="addtodo">
            <TextField
                label='Add Todo' ref="name"
            />
            <br />
            <TextField
                label='Add Description' ref="description"
            />
            <br />
            <PrimaryButton …
Run Code Online (Sandbox Code Playgroud)

redirect typescript reactjs react-router

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

标签 统计

react-router ×1

reactjs ×1

redirect ×1

typescript ×1