score:2
Accepted answer
Thanks to the comments, I was able to figure it out. I had to add an onBlur
prop to Input
like so:
export default class Input extends React.Component {
constructor() {
super();
this.handleBlur = this.handleBlur.bind(this);
}
handleBlur() {
const { onBlur } = this.props;
onBlur();
}
render() {
return <input onBlur={this.handleBlur} />
}
}
Input.propTypes = {
onBlur: PropTypes.func,
};
Input.defaultProps = {
onBlur: () => {},
};
score:0
after of a lot of search, I Did that with the follow code, in my case I am using React CS6.
class test extends React.Component {
onBlur() {
console.log('anything');
}
render () {
let { onBlur, onChange, value, ...props } = this.props;
return (
<input onBlur={ this.onBlur } />
);
}
}
Source: stackoverflow.com
Related Query
- How to check if a component has been clicked after an onblur event in React
- How to fire an event React Testing Library
- How to fire onBlur event in React?
- How to fire React Hooks after event
- How to fire an action event in react 16.8?
- For a component in React with Reux, how to not fire mouse event in one case and how to fire mouse event in another case
- React - How can I fire an Event listener just once?
- how to add pagination and fire row click event in table in react js
- How can I prevent event bubbling in nested React components on click?
- How to use onClick event on react Link component?
- React Formik : how to use custom onChange and onBlur
- React - how to capture only parent's onClick event and not children
- Updating a React Input text field with the value on onBlur event
- React - ul with onBlur event is preventing onClick from firing on li
- How to add scroll event in react component
- How can I add onKeyPress event to react material-ui textfield?
- How do you generate a blur or onBlur event in Enzyme?
- How to set event handler in React sub-component
- How to unit test a react event handler that contains history.push using Jest and Enzyme?
- How to pass an event handler to a child component in React
- How to simulate mouse over event on a div using enzyme for testing a react application?
- How can I propagate touch event in nested Touchable in React Native?
- How can I handle an event to open a window in react js?
- React Material-UI checkbox onChange event does not fire
- How to attach drag event handlers to a React component using TypeScript
- How to add Event in React Functional Component
- how to get list of all registered synthetic event handlers/listeners for a React Component?
- Trigger onblur event on click of enter keypress in React js
- How I can disable a button in React js for 5 seconds after click event
- Force React to fire event through injected JavaScript
More Query from same tag
- Error displaying dates from database in reactjs
- React: Checking if an image source / url is empty then return a different url?
- What is this condition syntax in react native code?
- How to increase Antd Collapse icon size and change it if collapse is expanded
- Firebase cloud functions direct app calling on client
- How to import data from .JSON file and iterate over it in React?
- how to get input value on button click in stateless component?
- How to dynamically change animation value in inline syle of ReactJS
- Create React Context that returns 2 Other Functions Through Context Provider
- Change props value outsite react and reload component
- Get pathname from window and store it in state to use in fetch function
- Material UI Dialog close dialog from inner component
- Multi-line for loop in JSX
- If true set attribute else set className in JSX
- Why doesn't React provide a transpiler?
- How to create dropdown list with description in React
- Semantic UI doesn't apply the theme specified in theme.config
- Trouble changing the link font color using typography.js in gatsby
- React-Redux Functional Component Multiple Renders
- Is there a way to set defaultValues in a child component using react hook form with useFieldArray hook - not using the useForm hook?
- Why did adding an extra button to my React Form cause both my buttons to stop working?
- Map function in react (err: TypeError: e.map is not a function)
- React state late update
- Alert component from Material UI not showing up?
- How to change Material-UI TextField bottom and label color on error and on focus
- How to Add React Js On an Existing Website?
- Can somone help me understand why these arrows arent showing IN react-multi-carousel?
- React-Select Remove focus border
- Many queries to API with javascript and some of them get 403
- react props undefined inside the constructor and exist inside the render