10 examples of 'onchange in react js' in JavaScript

Every line of 'onchange in react js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
89value: function onChange(ev) {
90 this.setState({
91 innerValue: ev.target.value,
92 isPristine: false
93 });
94
95 // execute callback
96 var fn = this.props.onChange;
97 fn && fn(ev);
98}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

25static getDerivedStateFromProps(nextProps, prevState) {
26 if (shouldMap(prevState.prevProps, nextProps)) {
27 return {
28 computedProps: propsMapper(nextProps),
29 prevProps: nextProps,
30 }
31 }
32
33 return {
34 prevProps: nextProps,
35 }
36}
51function handlePropsChanges(component, prev, next) {
52 var _changeHandlers = component._changeHandlers;
53 for (var name_1 in _changeHandlers) {
54 if (prev[name_1] !== next[name_1]) {
55 for (var _i = 0, _a = _changeHandlers[name_1]; _i < _a.length; _i++) {
56 var handler = _a[_i];
57 handler(next[name_1], prev[name_1], component);
58 }
59 }
60 }
61}
193onChange: function onChange(event) {
194 var value = event.target.value;
195
196 _this2.maybeEmitOnChange(event, value, 'type');
197 inputChanged('type');
198},
89onChange: function onChange(e) {
90 return _this2.setState({ dataWidth: e.target.value });
91}
47onChange: function onChange() {
48 return props.onChange(!value);
49}
338onChange: function onChange(e) {
339 return _this2.setState({ editingLayer: _this2.state.editingLayer.merge({ order: e.target.value }) });
340}
4componentDidUpdate(prevProps, prevState) {
5 if (
6 this.state.someStatefulValue !==
7 prevState.someStatefulValue
8 ) {
9 this.props.onChange(this.state.someStatefulValue);
10 }
11}
94value: function UNSAFE_componentWillReceiveProps(nextProps) {
95 if ('value' in nextProps) {
96 this.setState({
97 isEmpty: isEmpty(nextProps.value)
98 });
99 }
100}
77function handlePropsChanges( component : any, prev : object, next : object ){
78 const { _changeHandlers } = component;
79
80 for( let name in _changeHandlers ){
81 if( prev[ name ] !== next[ name ] ){
82 for( let handler of _changeHandlers[ name ] ){
83 handler( next[ name ], prev[ name ], component );
84 }
85 }
86 }
87}

Related snippets