Giter Site home page Giter Site logo

Comments (9)

Driklyn avatar Driklyn commented on June 19, 2024

I'm no React expert, but I'm using ref for this purpose, like so:

var App = React.createClass({
  render: function() {
    return (
      <div>
        <Geosuggest
          ref="geosuggest" />
      </div>
    );
  }

  clearSearch: function() {
    this.refs.geosuggest.clear();
  }
});

from react-geosuggest.

ro-ka avatar ro-ka commented on June 19, 2024

Does this help, @farrrr? Thanks, @Driklyn!

from react-geosuggest.

ro-ka avatar ro-ka commented on June 19, 2024

I suppose it is working, reopen if not!

from react-geosuggest.

BesatZardosht avatar BesatZardosht commented on June 19, 2024

I have same issue. I want to clear the input when I render the component. How can I do that?

from react-geosuggest.

ro-ka avatar ro-ka commented on June 19, 2024

Do you want to clear it on the first render? Then just provide an empty initialValue.
Do you want to clear it on every render call? Wouldn’t advice that…

You can call the clear like @Driklyn described above.

from react-geosuggest.

BesatZardosht avatar BesatZardosht commented on June 19, 2024

initialValue is not what I need. I neetd to clear it outside the component like, in its parent render. or by clicking a button.

When I try @Driklyn code I get this:
Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded

from react-geosuggest.

ro-ka avatar ro-ka commented on June 19, 2024

I cannot say what the problem is without any code. However, this is not related to the component, it’s general React.
Did you check with the mentioned advises in you component?

from react-geosuggest.

yfr avatar yfr commented on June 19, 2024

When adding this method to geosuggest (just quick and dirty test). We are able to get the current activeSuggest. But after that the suggestion list collapses and activeSugggest is reset.

This is a good thing as we do not want to have an activeSuggest when the list is not visible.

  selectActiveSuggest() {
    return this.state.activeSuggest;
  }

One solution would be that we have an exposed method to trigger geocodeSuggest return the response.

from react-geosuggest.

michalica avatar michalica commented on June 19, 2024

I am not sure but how can I call clear() on Focus when I use ES6 syntax?

from react-geosuggest.

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.