Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering a second TextInput doesn't wait for input #15

Closed
danrspencer opened this issue Mar 4, 2019 · 3 comments
Closed

Rendering a second TextInput doesn't wait for input #15

danrspencer opened this issue Mar 4, 2019 · 3 comments

Comments

@danrspencer
Copy link

danrspencer commented Mar 4, 2019

When rendering a new TextInput after getting another input from another TextInput the second input does not wait and the app will exit.

e.g.

import React from "react";
import { Box } from "ink/build";
import TextInput from "ink-text-input";

const Input1 = ({ value, onChange }) => (
  <Box>
    Input 1:
    <TextInput value={value ?? ""} onChange={onChange} />
  </Box>
);

const Input2 = ({ value, onChange }) => (
  <Box>
    Input 2:
    <TextInput value={value ?? ""} onChange={onChange} />
  </Box>
);

export default class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      input1: undefined,
      input2: undefined
    };

    this.onFirstInput = this.onFirstInput.bind(this);
    this.onSecondInput = this.onSecondInput.bind(this);
  }

  render() {
    return !this.state.input1 ? (
      <Input1 onChange={this.onFirstInput} />
    ) : (
      <Input2 onChange={this.onSecondInput} />
    );
  }

  onFirstInput(input1) {
    this.setState({
      input1
    });
  }

  onSecondInput(input2) {
    this.setState({
      input2
    });
  }
}

This will render Input 1: and wait for input. After pressing a key it will render Input 2: and then exit.

@danrspencer danrspencer changed the title Rendering a second text input doesn't wait for input Rendering a second TextInput doesn't wait for input Mar 4, 2019
@entrptaher
Copy link

I faced same issue.
Not only that, I cannot also submit the form.
Need to see if this is a ink 2 spectific problem.

@vadimdemedes
Copy link
Owner

Found it, fix coming up soon! Thanks for reporting ;)

@vadimdemedes
Copy link
Owner

Update to Ink 2.0.1 and it should be fixed. Let me know if it doesn't and I will re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants