question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make component observe on form data?

See original GitHub issue

My parent component includes a form data as below:

render() {
    const form = this.form;
    return (
      <div className="pt-dark ">
        <form className="profile-form" onSubmit={form.onSubmit}>
          <div className="profile-input-row">
            <Input field={form.$('alias')}/>
          </div>
          <div className="profile-input-row">
            <Input field={form.$('port')}/>
          </div>

Below is the Input component code:

export default observer(({field}) => (

  <div >
    <label  htmlFor={field.id}>{field.label}</label>
    <div className="input-content">
      <input  {...field.bind()} />
    </div>
  </div>
));

when I change the value of the input, my parent component doesn’t got rendered. How can I make my current component listen on the form state change?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zhaoyi0113commented, Mar 21, 2017

Yup, that should work. Thanks.

0reactions
foxhound87commented, Mar 21, 2017

So why not creating another store? Then pass it with @inject('store', 'form')

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending form data - Learn web development | MDN
As we'd alluded to above, sending form data is easy, but securing an application ... The <form> element defines how the data will...
Read more >
Different ways to get form data in Angular Component
1. Using formControlName (Reactive Form). Reactive forms provide a model-driven approach to handling form inputs whose values change over time.
Read more >
Collecting Form Data using JavaScript - YouTube
In this lecture, you will learn how to collect form data of different input fields in HTML using JavaScript and DOM.
Read more >
Angular 2/5 - Passing form data between components using ...
I have a form with multiple inputs and select menus etc and I'm trying to populate another form in another sibling component using...
Read more >
Working with Form Data in React - DevCamp
onSubmit = fields => { const { title, body, image } = fields; var formData = new FormData(); formData.append('title', title); formData.append('body' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found