Skip to content

Commit

Permalink
fix: Add component and child definition check (#28)
Browse files Browse the repository at this point in the history
Check if child is defined before checking it is of SUBMIT_TYPE
  • Loading branch information
tpucci authored and Almouro committed Mar 6, 2018
1 parent d63c345 commit 06f0e50
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const errorMessages = {

const SUBMIT_TYPE = 'submit';

const isInput = component => component.props.type && component.props.type !== SUBMIT_TYPE;
const isInput = component =>
component && component.props.type && component.props.type !== SUBMIT_TYPE;

class Form extends PureComponent {
static defaultProps = {
Expand Down Expand Up @@ -197,7 +198,7 @@ class Form extends PureComponent {
}

renderChild = (child: _ReactComponent) => {
if (child.props.type === SUBMIT_TYPE) {
if (child && child.props.type === SUBMIT_TYPE) {
return React.cloneElement(child, {
onPress: () => this.onSubmit(),
key: 'submit',
Expand Down

0 comments on commit 06f0e50

Please sign in to comment.