My components looks like:
App.jsx
import MyInput from './MyInput';
const onChangeHandler = (val) => {
console.log(val);
};
export default {
render() {
return (
<MyInput onChange={onChangeHandler} />
);
},
};
and MyInput.jsx
export default {
props: {
onChange: {
type: Function,
},
},
render() {
// as Sphinx suggested it should be this.$props.onChange
return (
<input onChange={this.$props.onChange} />
);
},
};
But this.onChange is undefined:
How to properly use this.onChange prop in MyInput component?
CodePen
Here you can find CodePen with implementation of my problem: https://codepan.net/gist/13621e2b36ca077f9be7dd899e66c056

this.props.onChange? Admittedly it's been a while since I've worked with Vue.this.props is undefinded_this.$propsthis.$props.onChange,this.props.onChange,_this.$props.onChangeandthis.onChangeall of them failed._this.$props? I created one demo below, it works fine. did you pass correct value like<my-input :on-change="function(){}"></my-input>?