Giter Club home page Giter Club logo

Comments (6)

joepuzzo avatar joepuzzo commented on June 6, 2024

You can hook into onChange or onSubmit yes

from informed.

jacargentina avatar jacargentina commented on June 6, 2024

Nope.

Redux has mapStateToProps in which any state should be made available to components via props. In this case for example:

import { Form, Text } from 'informed';
import PathBrowser from './PathBrowser';

class MyComponent extends React.Component {
  render() {
    return (
      <Form
        initialValues={this.props.editing}
        render={() => (
          <div>
            <Text field="path" id="path" autoFocus />
            <PathBrowser onSelectedChanged={this.props.pathChanged} />
          </div>
        )}
      />
    );
  }
}

const mapStateToProps = state => {
  return {
    editing: state.obj // obj = { path: 'the string for the path' };
  };
};

const mapDispatchToProps = dispatch => {
  return {
    pathChanged: newPathStr => {
      dispatch(updateObj('path', newPathStr));
    }
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(Mycomponent);

I don't know the internals of informed, so I suspect that when I provide an obj instance with some data, initialValues makes them available to every field on its editors; but I don't know how would <Text /> know that the pathvalue has changed after calling the pathChangedhandler?

My example works fine when I'm editing the values myself, but is not getting the value I send via the event.

from informed.

joepuzzo avatar joepuzzo commented on June 6, 2024

I guess i don’t understand your use case.. you want to set it up such that when a user types in the text field that it calles your path changed action? Correct?

from informed.

Mairu avatar Mairu commented on June 6, 2024

A change to intialValues will not update the form values, I think that is his problem.
To change values after initialization you have to call setValues of the formApi.

from informed.

joepuzzo avatar joepuzzo commented on June 6, 2024

Yeah you would call setValue if you needed to set the value dynamically based on some other change.

from informed.

jacargentina avatar jacargentina commented on June 6, 2024

Great! Thanks for the advice.

from informed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.