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

call clean() outside Geosuggest section #54

Closed
farrrr opened this issue Oct 4, 2015 · 9 comments
Closed

call clean() outside Geosuggest section #54

farrrr opened this issue Oct 4, 2015 · 9 comments

Comments

@farrrr
Copy link

farrrr commented Oct 4, 2015

I have a button to clean form input value include geosuggest.

How to call clean() outside geosuggest section?

@Driklyn
Copy link
Contributor

Driklyn commented Oct 13, 2015

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();
  }
});

@ro-ka
Copy link
Contributor

ro-ka commented Oct 15, 2015

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

@ro-ka
Copy link
Contributor

ro-ka commented Oct 21, 2015

I suppose it is working, reopen if not!

@ro-ka ro-ka closed this as completed Oct 21, 2015
@BesatZardosht
Copy link

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

@ro-ka
Copy link
Contributor

ro-ka commented Apr 18, 2016

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.

@BesatZardosht
Copy link

BesatZardosht commented Apr 18, 2016

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

@ro-ka
Copy link
Contributor

ro-ka commented Apr 18, 2016

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?

@yfr
Copy link
Member

yfr commented Sep 23, 2016

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.

@michalica
Copy link

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

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

6 participants