score:0
i had the same issue a while back.
here's how i fixed it -
history.js
import { createbrowserhistory } from 'history';
export default createbrowserhistory();
app.js
class app extends component {
render() {
return(
<router history={history}>
<router history={history}>
<switch>
<route
path="/sign-up"
render={(props) => <signupform {...props} />}
/>
<privateroute
exact
path={routes.home}
component={homepage}
/>
</switch>
</router>
);
}
}
signupform.js
import history from "./routes/history";
class signupform extends react.component {
handlesignup = (e) => {
//add your success logic here
history.push("/home");
}
render() {
return (
<form onsubmit={this.handlelogin}>
<div classname="form-submit">
<button
variant="outline-success"
size="xs"
block
type="submit"
>
submit
</button>
</div>
</form>
</div>
</div>
);
}
}
Source: stackoverflow.com
Related Query
- Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
- Constructor props equivalent in React Hooks for history push
- Why is React component rerendering when props has not changed?
- Why are my props not being passed into my component when mount rendering?
- reactjs: connected-router is not redirecting the user after push call is made
- Why are my component's redux-based props not updating?
- Why does React re-renders children when props does not change?
- Why child component's render is called when props did not change?
- Why is props.history.push() is not redirecting
- Why React component is not update when the props passed to it changes?
- Why does moving the array map of props outside the render function not work in React?
- React: Props - Why does one work, but another not
- why I am not getting updated props value in react
- why Passing Props in Private Route in ReactJs not working properly
- React Redux: Why is this nested component not receiving props from redux state?
- Why does slice push work in redux but not concat?
- Why is this react handleChange not working? Trying to handle a change received by props
- Why is my login component not redirecting successful login's to the right page?
- Why props is not being passed by history.push?
- React Router -- history push state not refreshing with new state object
- Why does this React/Mobx observer component not rerender when its observable props change?
- Why pristine props does not disable button for both Redux-Fields
- History push undefined when using props within Axios getData in React
- Why render is not triggered even the props changed
- Why null/undefined checks does not work in Classes with extendable props interface in Typescript
- Why is my method Render Props of the React Component not working?
- Why can I not pass props to child component React?
- why changing state does not trigger if it's related to props
- Why useEffect is not called, when props have changed, render is called?
- Why are React props not updated in event handler
More Query from same tag
- How does webpack pick a relative path inside node_modules ? does it reference package.json at all?
- How to make texts appear below icons in Buttons (Material UI)
- Have scrollable div fill up the above of BottomNavigation bar?
- Drop-down menu cannot use in multiple places
- web manifest: Line: 1, column: 1, Syntax error
- Remove Label on Material-UI Select Text Field
- React Typescript and useCallback
- How to hide a child element as default and show it when users over over a parent element with material ui(react.js)?
- My ReactJS/Django(Rest API) prompts an Unhandled Promise rejection when I browse from a different PC on the LAN
- Errors after upgrading to Babel 7
- How to make my menu on the same horizontal line?
- BrowserRouter in React leading to "invalid hook calls"
- Syntax Highlighting for CSS in a Style Tag in a TSX Component
- React hide dropdown menu when lose focus
- How to tell if Gatsby Image component has loaded?
- Prevent route from being rendered
- Array of components in ReactJS
- jest testcase failing in react
- DRY with Props in React
- reactjs: usestate with object, values not getting changed
- How can I change step from child component?
- How to iterate through an Array of objects in React
- OnClick is not working, but no errors appear in the console
- styling issue after removing footer from antd design
- Selenium (Python) + React
- Hide Drawer Under Curved Header with Material UI and CSS
- React onClick with axios is refresh after sent
- Uncaught Error:React limits the number of renders to prevent an infinite loop ( ReactAnimatedWeather )
- Twilio Web Chat Channel Listener
- React setState : unable to update state object