changeHandler = e => {
const { target } = e;
const { name } = target;
const value = target.type === 'checkbox' ? target.checked : target.value;
this.setState({
data: {
[this.state.id]: {
...this.state.data[this.state.id],
[name]: value,
},
},
});
};
changeHandler = e => {
const { target } = e;
const { name } = target;
const value = target.type === 'checkbox' ? target.checked : target.value;
this.setState({
data: {
[this.state.id]: {
[name]: value,
},
},
});
};
export const IMAGE_FETCH_REQUESTED = 'IMAGE_FETCH_REQUESTED';
import { IMAGE_FETCH_REQUESTED } from './constraints/images';
export const searchImage = value => ({ type: IMAGE_FETCH_REQUESTED, payload: value });
import { searchImage } from '/actions/images';
class ExampleComponent extends React.Component {
input = React.createRef();
handleClick = e => {
this.props.searchImage(this.input.value);
this.input.value = '';
};
render() {
return (
<Form>
<Input innerRef={this.input} placeholder='Search' />
<Button type='button' onClick={this.handleClick}>GO</Button>
</Form>
);
}
}
const mapDispatchToProps = {
searchImage,
}
connect (null, mapDispatchToProps)(ExampleComponent);
import {uniqueId} from 'lodash';
export class Home extends React.Component {
static uid = uniqueId();
// some code..
}
Home.uid