mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Add Form component to wrap forms with some default props
This commit is contained in:
parent
1bf7cc9963
commit
cfae14105e
2 changed files with 35 additions and 0 deletions
33
src/components/Form/Form.js
Normal file
33
src/components/Form/Form.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import React, { PropTypes } from 'react';
|
||||
|
||||
const Form = props => {
|
||||
const { children, ...restProps } = props;
|
||||
|
||||
const formProps = {
|
||||
// These are mainly default values for the server
|
||||
// rendering. Otherwise the form would submit potentially
|
||||
// sensitive data with the default GET method until the client
|
||||
// side code is loaded.
|
||||
method: 'post',
|
||||
action: '/',
|
||||
|
||||
...restProps,
|
||||
};
|
||||
return (
|
||||
<form {...formProps}>
|
||||
{children}
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
Form.defaultProps = {
|
||||
children: null,
|
||||
};
|
||||
|
||||
const { node } = PropTypes;
|
||||
|
||||
Form.propTypes = {
|
||||
children: node,
|
||||
};
|
||||
|
||||
export default Form;
|
||||
|
|
@ -15,6 +15,7 @@ import EditListingWizard from './EditListingWizard/EditListingWizard';
|
|||
import ExpandingTextarea from './ExpandingTextarea/ExpandingTextarea';
|
||||
import ExternalLink from './ExternalLink/ExternalLink';
|
||||
import FilterPanel from './FilterPanel/FilterPanel';
|
||||
import Form from './Form/Form';
|
||||
import HeroSection from './HeroSection/HeroSection';
|
||||
import IconBannedUser from './IconBannedUser/IconBannedUser';
|
||||
import IconCheckmark from './IconCheckmark/IconCheckmark';
|
||||
|
|
@ -96,6 +97,7 @@ export {
|
|||
ExpandingTextarea,
|
||||
ExternalLink,
|
||||
FilterPanel,
|
||||
Form,
|
||||
HeroSection,
|
||||
IconBannedUser,
|
||||
IconCheckmark,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue