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.

[v2] - Does Value Not exist anymore?

See original GitHub issue

Hi

I am looking through the examples and I don’t see “value”

in 1.0 example

 <Select
        name="form-field-name"
        value={selectedOption}
        onChange={this.handleChange}
        options={[
          { value: 'one', label: 'One' },
          { value: 'two', label: 'Two' },
        ]}
      />

in 2.0 example

const MyComponent = () => (
  <Select options={options} />
)

I am using this plug: https://github.com/jaredpalmer/formik and what I am finding is all my values in “select” are disappearing and I am starting to think that the problem might be because the “value” is not set as that is what I see them doing in this example: https://codesandbox.io/s/jRzE53pqR

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chobo2commented, Jul 23, 2018

@juank11memphis

import React, { Component } from "react";
import Select from "react-select";
import { observer } from "mobx-react";

@observer
export default class SelectWrapperComponent extends React.Component {
  handleChange = value => {
    // this is going to call setFieldValue and manually update values.topcis
    this.props.onChange(this.props.selectName, value);
  };

  handleBlur = () => {
    // this is going to call setFieldTouched and manually update touched.topcis
   this.props.onBlur(this.props.selectName, true);
  };

  render() {
    const props = this.props;
    return (
      <React.Fragment>
        <Select
          options={props.options}
          isMulti={props.isMulti}
          onChange={this.handleChange}
          onBlur={this.handleBlur}
          closeMenuOnSelect = {props.closeMenuOnSelect}
          value = {this.props.value}
        />
      </React.Fragment>
    );
  }
}


<Formik
initialValues={{
  selected: "",
}}
validationSchema={Yup.object().shape({
})}
onSubmit={(values, { setSubmitting, setErrors }) => {
}}
render={props => (
  <Form autoComplete="off">

        <SelectWrapperComponent
          options={contacts}
          onChange={props.setFieldValue}
          onBlur={props.setFieldTouched}
          selectName="selected"
          isMulti={false}
          closeMenuOnSelect={true}
          value={props.values.selected}
        />
        <ErrorMessage name="selected" />
  </Form>
)}
/>

0reactions
juank11memphiscommented, Jul 24, 2018

Hi @chobo2 thanks a lot for the code, I will try it tonight and let you know if it worked but I already notice some things that I may be doing wrong. thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Riverpod 2.0: override with value does not exist anymore
I have a provider named gameControllerProvider extends with ChangeNotifier, I initialize it first throw UnimplementedError. final ...
Read more >
What does it mean when a value of a function does not exist ...
We are who make the functions, we can decit: a value of a function exists or does not exit. Sometime there is not...
Read more >
How to Determine if a Limit Does Not Exist - Study.com
Determining if a limit does not exist requires information about the limit type, its asymptote, and graphed point.
Read more >
When Do Limits Exist or Not Exist? - YouTube
This tutorial discusses when limits exist or don't exist (commonly written DNE). Two graphical examples are shown and three algebraic ones ...
Read more >
Example of Functions where Limits does not exist - YouTube
Limits and Continuity Test: https://www.youtube.com/watch?v=oQjjdPowWXE&list=PLJ-ma5dJyAqro5PFN-FZ5T8PjAy9kyIeT&index=5.
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