I am trying to create very simple multistep form using react. My main component which is handling state for steps looks like this:
...
renderStepItem = () => {
switch(this.state.step) {
case 1:
return <ImportStep nextStep={this.nextStep} />
case 2:
return <ImportStep previousStep={this.previousStep} nextStep={this.nextStep} />
case 3:
return <ImportStep previousStep={this.previousStep} />
}
}
...
This is switch which should return Component that should be rendered based on step state
Then render:
render() {
return(
{this.renderStepItem()}
)
}
The problem is that i am getting following error message:
Error
Objects are not valid as a React child (found: object with keys {nextStep}).
I was trying to go through some tuts etc to solve it. But i am guessing that i am passing something that i am unable to do.
Can anybody give me some hint please?
UPDATE:
render() {
const importSteps = AppConfig.importSteps;
return (
<Block extend={{
width: '80%',
margin: '25px auto'
}}>
<TabNav extend={{
border: '1px solid black',
}}
textAlign='center'>
{Object.keys(importSteps).map(function(key) {
return <TabNavItem >{importSteps[key].name} {importSteps[key].stepNo}</TabNavItem>;
}
)}
</TabNav>
<div>{ this.renderStepItem() }</div>
</Block>
)
}
}
UPDATE2: ImportItem component
import React, { Component } from 'react';
import { Block } from 'vcc-ui';
class ImportStep extends Component {
render() {
return (
<Block>
<h3>{this.props}</h3>
</Block>
)
}
}
export default ImportStep;
return (<ImportStep nextStep={this.nextStep} />)(notice the added parenthesis, apply to each return statement)ImportStep?nextStepproperty on it. If you can provide the missing code (ie, both render methods), perhaps we can help narrow it down.