score:1
the function handlechange
should get only an event as a parameter.
handlechange(e)
this event is attached to the target element, so you can access its values via e.target.value
;
with that said, do not bind
the handlers in the render
function. do it in the constructor
as it will create a new instance of the handler
on each render
call. bad for performance.
as for the redux
flow, you should use connect
.
export default connect(mapstatetoprops, mapdispatchtoprops)(testing)
.
edit
after another look at your code, beside the fact that you didn't use connect
to connect the component to redux
, you are mapping a wrong object to mapdispatchtoprops
.
in this code you are using loginaction
:
function mapdispatchtoprops(dispatch) {
return {
actions: bindactioncreators(loginaction, dispatch)
}
}
but you never imported it, you used a name import:
import { loginsuccess, loginrequest, login } from '../actions/loginaction';
one possible way to import everything and pass it to mapdispatchtoprops
is this:
import * as loginaction from '../actions/loginaction';
another mistake you made is naming this object with different name on proptypes
, you named it actions
and not loginaction
testing.proptypes = {
actions: proptypes.object.isrequired,
};
you will need the same name:
testing.proptypes = {
loginaction: proptypes.object.isrequired,
};
and again don't forget to connect
!!
score:0
i believe you need to connect your component to redux.
import { connect } from 'react-redux'
// your code
export default connect(mapstatetoprops, mapdispatchtoprops)(testing)
don't forget to remove export default
from before your class as well.
edit: please use setstate
if you're planning on modifying the local state of a component.
Source: stackoverflow.com
Related Query
- Failed prop type The prop is marked as required but its value is `undefined`
- Warning: Failed prop type: The prop `store` is marked as required in `Provider`, but its value is `undefined`. in Provider
- Warning: Failed prop type: The prop `to` is marked as required in `Link`, but its value is `undefined`
- Warning: Failed prop type: The prop open is marked as required in Snackbar, but its value is undefined
- Failed prop type: The prop `userSignUpRequest` is marked as required in `Login`, but its value is `undefined`
- reactjs Delete Operation Warning: Failed prop type: The prop `role` is marked as required in `ManageRolePage`, but its value is `null`
- Failed prop type: The prop `value` is marked as required in `Rating`, but its value is `undefined`
- Failed prop type: The prop todos[0].id is marked as required in TodoList, but its value is undefined
- Warning: Failed prop type: The prop `value` is marked as required in `TextInput`, but its value is `undefined`
- Warning: Failed prop type: The prop `theme` is marked as required in `MuiThemeProviderOld`, but its value is `undefined`
- Using GatsbyImage - I keep getting an error Failed prop type: The prop `image` is marked as required in `GatsbyImage`, but its value is `undefined`
- Warning: Failed prop type: The prop `term` is marked as required in `ParentComponent`, but its value is `undefined`
- Warning: Failed prop type: The prop `todos[0].title` is marked as required in `TodoList`, but its value is `undefined`
- Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`
- Failed prop type: The prop `children` is marked as required in `Mutation`, but its value is `undefined`
- Failed prop type: The prop `children` is marked as required in` Sidebar`, but its value is `undefined`
- Failed prop type: The prop `id` is marked as required in `FormattedMessage`, but its value is `undefined`
- Warning: Failed prop type: The prop `createCourse` is marked as required in `CoursesPage`, but its value is `undefined`
- Failed prop type: The `` is marked as required in ``, but its value is `undefined`
- Failed prop type: The prop `actions` is marked as required in `Testing`, but its value is `undefined`
- Failed prop type: The prop `location` is marked as required in `PrivateRoute`, but its value is `undefined`
- Warning: Failed prop type: The prop `alt` is marked as required in `MainImage`, but its value is `undefined`. MainImage
- How to fix this issue “Warning: Failed prop type: The prop `title` is marked as required in `Tab`, but its value is `undefined`.”
- Failed prop type: The prop `message` is marked as required in `Description`, but its value is `undefined`
- warning.js:36 Warning: Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`
- Failed prop type: The prop `setToken` is marked as required in `Login`, but its value is `undefined`
- Using .map and getting Warning: Failed prop type: The prop `to` is marked as required in `Link`, but its value is `undefined`
- Warning: Failed prop type: The prop `exercise` is marked as required in `EditExercise`, but its value is `undefined`
- Failed prop type: The prop `options` is marked as required in `signupCheckBoxes`, but its value is `undefined`
- Warning: Failed prop type: The prop `id` is marked as required in `User`, but its value is `undefined`
More Query from same tag
- Get state variable from child component using React 16.8^ coding style
- How to import downloadjs into react js file?
- How to show temporary message in ReactJS until API endpoint comes back
- css doing nothing - referencing issue - font awesome icon - react
- How to access client-side window method in Next.js
- React Hooks: accessing state across functions without changing event handler function references
- ReactJS: unhide + focus an input field
- `forwardRef` error when dynamically importing a module in Next.js
- ReactJs: How to add/append a component on click of button
- Accessing document.cookie returns empty string even though cookies are listed in developer tools with httpOnly flag set to false
- React: useEffect vs useMemo vs useState
- React Spring translate animation not working and clicking on a list item seems to be delayed
- value is always empty inside ternary operator statement
- Image from json file is not displayed on the website
- How access those values in React?
- What's the difference between useCallback and useMemo
- React Testing Library can't see result of useState update function
- How to use Express routes with React.js frontend?
- ReactJS: Array passed to child as props from fetch API call return undefined
- Update context when state object mutates
- momentjs returns an object
- Validation Table Items on add
- ReactJS: Extend, Override CSS class
- ReactJS - Dynamic Routes
- Make animated collapsible card component, with initial props to show or hide
- Nextjs Idle time
- Change the height of a snackbar
- FontAweSome, why? Type '"acquisitions-incorporated"' is not assignable to type 'IconName'
- How to load the js and css files from other than root when creating a build?
- How to redirect to home page(in jsx) after logout in react