score:0
You need to define your function
function isValidated(){
alert("checking isValidated calling")
return this.state.count > 2
}
you need to add function
before your function name.
And if it is ES6
const isValidated = () => { }
score:0
It just works without connecting Redux due to connect()
function always return a new Component and it will not have isValidated
method you wrote.
You can use connect()
function at MultiStep
component and pass props
to child components. You can see my code:
...
class MultiStep extends Component {
render() {
const {example} = this.props
const steps = [
{ name: 'step1', component: <RegistrationType {...example} /> },
{ name: 'step2', component: <PersonalDetails /> },
{ name: 'step3', component: <ContactDetails /> }
]
return (
<Fragment>
<h1 className="page-header">Register for New Account</h1>
<StepZilla
steps={steps}
stepsNavigation={true}
nextButtonText='Save and Continue'
backButtonText='Back'
nextButtonCls="btn btn-warning active pull-right mr-0"
backButtonCls="btn btn-primary pull-left ml-25"
hocValidationAppliedTo= {[0,1, 2]}
/>
</Fragment>
);
}
}
..
...
export connect(mapStateToProps, mapDispatchToProps)(MultiStep)
score:0
you can do something like this, send props to your steps rather than using redux connect. this is extra long code but it may help some, understand what is happening.
class MultiStep extends Component {
render() {
const steps = [
{ name: "General Info", component: <StepOne {...this.props} /> },
{ name: "Personal Info", component: <StepTwo {...this.props} /> },
{ name: "Educational Info", component: <StepThree {...this.props} /> },
{ name: "Address", component: <StepFour {...this.props} /> },
{ name: "Account Info", component: <StepFive {...this.props} /> },
{ name: "Review", component: <StepSix {...this.props} /> },
{ name: "Done", component: <StepSix {...this.props} /> }
];
return (
<StepZilla
steps={steps}
stepsNavigation={true}
nextButtonText="Save and Continue"
backButtonText="Back"
//hocValidationAppliedTo={[0, 1, 2, 3, 4, 5, 6]} //commenting this worked for me.
nextButtonCls="btn btn-prev pull-right nextBtn btn-color"
backButtonCls="btn btn-next btn-color"
/>
);
}
}
// export default MultiStep;
const mapStateToProps = state => ({
errors: state.errors
});
const mapDispatchToProps = {
setGeneralInfo,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(MultiStep);
and in the steps you can write your isValidated method in your component.
isValidated = () => {
const genInfo = {
employee_name: this.state.employee_name,
employee_code: this.state.employee_code,
employee_email: this.state.employee_email,
password: this.state.password,
};
console.log(genInfo);
this.props.setGeneralInfo(genInfo, this.props.jumpToStep);
return false; // make it return false. just in case. lol
};
and in your action
export const setGeneralInfo = (generalDetails, jumpToStep) => dispatch => {
console.log("gen details:", generalDetails);
Api.setGeneralInfo(generalDetails)
.then(res => {
console.log("res gen details:", res);
jumpToStep(1); //<<<< JUMP STEPS FROM HERE <STEPS START FROM 0>
return dispatch({
type: SET_GENERAL_INFO,
payload: res.data
});
})
.catch(err => {
//jumpToStep(0);
console.log("err gen details:", err.response);
return dispatch({
type: GET_ERRORS,
payload: err.response.data
});
});
};
Source: stackoverflow.com
Related Query
- IsValidated not working with redux in react stepzilla
- React router v4 not working with Redux
- React Redux is not working as expected with Next.js & NodeJS
- Initial state in React with Redux not working
- Protected Routes React Router 4 not working with auth state stored in Redux
- React Router / Redux / HOC not working with 'render' prop
- withRouter not working correctly with redux - react redux react-router
- React router dom v6 using useNevigation is not working with redux
- Changing setTimeout not working in React with Redux
- React Router with custom history not working
- React Error Boundaries not working with React
- React JS not working with Internet Explorer 9
- React Native Image Not Working with specific URL
- React hook useRef not working with styled-components and typescript
- React Router 4.x - PrivateRoute not working after connecting to Redux
- Paste from clipboard not working with React Native on iOS simulator
- Google analytics with react is not working
- require function not working with image in react
- Search not working with React material-table using remote data
- react props not updating with redux store
- connect redux function is not working with react-native
- Font Awesome 5 icons not working with React ("Could not find icon" error)
- Media queries not working with styled components in React App
- React router not working with params
- React render not working with createElement
- Keydown/up events with React Hooks not working properly
- Recharts is not working for the React with typescript
- React - New Context API not working with Class.contextType, but works with Context.Consumer
- React Context not working with server side rendering
- Replace of setState callback in react hook with useEffect hooks for complicated scenario not working
More Query from same tag
- React + Docker + Nginx
- Redux / React: dispatch action while mapping over store
- .reset() method results in error in typescript to reset forms
- React unique key - Index and ID are not unique key prop
- Radio Buttons onChange event
- React Hooks Change Text of Button on Click and then back again
- Unable to render component in react
- Passing styling options using JSS/Material-UI
- How can I disable the Highstocks range selector buttons when loading data asynchronously?
- What happens when setState is invoked?
- Where does one hold service instances in a react/redux application?
- Import SVG icons from another folder
- React TSX tag params with quotes
- How to connect Threejs to React?
- i18n-next Binding not working for deep JSON objects?
- How to unit test reactjs component?
- Child does not update when generated via array react
- Displaying arrow to popover in material UI
- Switching image src with images from an array on an interval in React
- React Typescript trying to change state of an array objects resulting in error
- React Storybook not displaying SVG icons
- React accessing state from a dynamically generated form, multiple levels deep
- collapsing all other menu when one is expanded
- Importing data from excel and displaying in a react component
- Using Async await in react component
- How can i change button style dynamically in React?
- How can I show a react component in all routes except one?
- unable to access to an url using react-router-dom
- Store does not have a valid reducer?
- Can't customize background of a Tooltip popup?