score:0
not 100% this is your problem but i would recommend against trying to bind on the form or whatever. assuming you're storing the input in the state's user object, then you just want to define a submit method, and call it with this.state.user
. that method should basically just call your api method.
import react, { component } from 'react'
import { adduser } from '../../actions/adduseraction'
import adduserform from './views/adduserform'
import { connect } from 'react-redux'
class addusercontainer extends component {
submit(values) {
console.log(values)
this.props.adduser(values)
}
render() {
return (
<div>
<h1>bjud in användare</h1>
<adduserform onsubmit={this.submit(this.state.user)} />
</div>
)
}
}
function mapstatetoprops(state) {
return { user: state.user }
}
export default connect(mapstatetoprops, { adduser })(addusercontainer)
score:1
in your adduserform.js
here you have to add onsubmithandler
as a prop for taking in the submit function that's suppose to run on form submit. you then have to pass the onsubmithandler
to handlesubmit()
import react from 'react'
import { field, reduxform } from 'redux-form'
const adduserform = ({ handlesubmit, onsubmithandler }) => {
return (
<form onsubmit={handlesubmit(onsubmithandler)}>
<div>
<field name="email" component="input" type="email" />
</div>
<button type="submit">bjud in</button>
</form>
)
}
export default reduxform({
form: 'adduser'
})(adduserform)
in your addusercontainer.js
change onsubmit={this.submit.bind(this)}
to onsubmithandler={this.submit.bind(this)}
Source: stackoverflow.com
Related Query
- Redux Form - You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop
- (Redux Form) You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop
- You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop | Redux Forms
- Uncaught Error: You must either pass handleSubmit() an onSubmit function or pass onSubmit as a prop
- You must pass a component to the function returned by connect. Instead received undefined
- Redux/React. You must pass a component to the function returned by connect. Instead received undefined
- Error: You must pass a function as a selector to useSelector
- why show error[ You must pass a component to the function returned by connect. Instead received undefined] in react redux
- React-router error: super expression must either be null or a function
- React 0.14.2 error - Super expression must either be null or a function
- How to pass in a second argument on ReactJS onSubmit function call
- How do you pass data when using the navigate function in react router v6
- React Native - Super expression must either be null or a function
- Super expression must either be null or a function (Custom Marker)
- how do you pass a generic type to an anonymous function in typescript tsx file
- Why must I pass a function to the setter function of 'useState' in React?
- React confetti: Super expression must either be null or a function
- How to fixed error: "You must pass a component to the function returned by connect. Instead received {}", in my React-Redux app?
- How pass a function into an own react context provider which lets you edit the state?
- Reactjs, Super expression must either be null or a function
- How do you pass an onClick function to grandchild component in React?
- Must specify either a render prop, a render function as children, or a component prop to Field(auto)
- Error: Super expression must either be null or a function
- how do you pass a React hook useState() 's callback function to a web component's attribute using Lit HTML
- How do you pass a function through a component that has a spread operator?
- Pass a function with predefined parameter to handleSubmit in React
- okta-auth-js Uncaught TypeError: Super expression must either be null or a function
- You must pass a valid ReactElement | Sweetalert-react
- How do you pass a callback function to a sibling component in React
- Can you pass a Stateful Component a function to run inside componentDidMount()?
More Query from same tag
- How to assign a value to an object property using variable?
- Using JQuery inside React
- Set state does not update the dropdown checkboxes - Using hooks
- Why won't my Redux change state change at all?
- ReactJS:: Issues with loading images while showing spinner
- How to pass fill colors to recharts Pie component
- Validate Correct URL With Http Status Code
- React does not recognize defined function
- Using Morris.js with reactjs
- Correct way to handle undefined declaration files (index.d.ts)
- Material UI TextField with type datetime-local date picker with seconds
- Multiple forEach statements on this.prop causes error
- React Private Route redirects before firebase user is loaded
- React - How do you call a function from inside another function
- How to Route without reloading the whole page?
- How to have useEffect() act like componentDidMount()?
- Should a setState function be a dependency of useEffect when passed via hook
- How to implement react static scss into project?
- How can I set the minimum and maximum value for the TextField?
- How to handle routing logic to prevent infinite loop in componentDidUpdate?
- Material-UI TextField inside Popper inside Dialog not working
- I want to change the state of a single book in my react app but it changes state of the whole array
- How to use local webfont in imported sass file?
- How to correctly infer React props from as prop with generic overload
- How can I solve this problem. React Router not updating routing on hosting
- How to add an svg image so that it highlights on hover
- react redux two components
- Connected Router - newly routed page contains additional data
- npm start gives Error: `output.path` needs to be an absolute path or `/`
- Is there a way to make nextjs Image have fixed height and responsive width?