re: Fast & easy... React states management in one function VIEW POST


You can try this alternative instead that doesn't require you to add any instance method (methods declared using arrow fns).

import React from "react";

// you can move this fn to an independent module and import it here
const setState = (component, updateState) => params =>

const setName = event => prevState => ({
  name: e.target.value

export default class App extends Component {
  state = {
    name: ""

  render() {
    return (
          placeholder="insert your name" value={this.state.name} 
          onChange= {setState(this, setName)} />
code of conduct - report abuse