Skip to content
Permalink
Browse files

Commonrize about Input

  • Loading branch information...
snamiki1212 committed May 4, 2019
1 parent adf2e86 commit 13008af06985c8ce6a4fcb89566085f4b0b5e66f
Showing with 16 additions and 21 deletions.
  1. +13 −0 src/components/Input.tsx
  2. +2 −11 src/containers/InputCount.tsx
  3. +1 −10 src/containers/InputName.tsx
@@ -0,0 +1,13 @@
import React from 'react';

const Input = ({ handleChange, value, type}: any) => {
return(
<input
type={type}
value={value}
onChange={(event) => handleChange(event.target.value)}
/>
)
}

export default Input;
@@ -1,6 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import { inputCount } from '../actions';
import Input from '../components/Input';

const mapStateToProps = (state: any) => ({
value: state.inputCount,
@@ -11,17 +12,7 @@ const mapDispatchToProps = (dispatch: any) => ({
handleChange: (count: number) => dispatch(inputCount(count)),
})

const InputCount = ({ handleChange, value, type}: any) => {
return(
<input
type={type}
value={value}
onChange={(event) => handleChange(event.target.value)}
/>
)
}

export default connect(
mapStateToProps,
mapDispatchToProps,
)(InputCount);
)(Input);
@@ -1,6 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
import { inputName } from '../actions';
import Input from '../components/Input';

const mapStateToProps = (state: any) => ({
value: state.inputName,
@@ -11,16 +12,6 @@ const mapDispatchToProps = (dispatch: any) => ({
handleChange: (name: string) => dispatch(inputName(name)),
})

const Input = ({ handleChange, value, type }: any) => {
return(
<input
type={type}
value={value}
onChange={(event) => handleChange(event.target.value)}
/>
)
}

export default connect(
mapStateToProps,
mapDispatchToProps,

0 comments on commit 13008af

Please sign in to comment.
You can’t perform that action at this time.