mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 14:24:33 +08:00
28 lines
626 B
JavaScript
28 lines
626 B
JavaScript
import React, {PropTypes} from 'react';
|
|
|
|
const Wizard = (props) => {
|
|
const {children, currentStep, ...rest} = props;
|
|
return (
|
|
<section>
|
|
{React.Children.toArray(children)
|
|
.filter((child, i) => i === currentStep)
|
|
.map((child, i) =>
|
|
React.cloneElement(child, {
|
|
i,
|
|
currentStep,
|
|
...rest
|
|
})
|
|
)}
|
|
</section>
|
|
);
|
|
};
|
|
|
|
Wizard.propTypes = {
|
|
currentStep: PropTypes.number.isRequired,
|
|
nextStep: PropTypes.func.isRequired,
|
|
previousStep: PropTypes.func.isRequired,
|
|
goToStep: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default Wizard;
|