Home Redirect in React with Typescript
Reply: 0

Redirect in React with Typescript

user1122 Published in May 24, 2018, 3:51 pm

I am working on React with Typescript. "Redirect" doesn't seem to work for me. I don't know what the problem is.

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">
                label='Add Todo' ref="name"
            <br />
                label='Add Description' ref="description"
            <br />
            <PrimaryButton text="Add" onClick={this.addTodo.bind(this)} />


You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.339088 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO