GithubHelp home page GithubHelp logo

Uncaught Error: flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering about react-bootstrap-typeahead HOT 4 CLOSED

duhmojo avatar duhmojo commented on August 18, 2024
Uncaught Error: flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering

from react-bootstrap-typeahead.

Comments (4)

duhmojo avatar duhmojo commented on August 18, 2024 1

I was inspecting _this in hideMenu and the inputNode can be used to detect if the menu is rendered in the DOM. e.g. if _this.inputNode.offsetParent is undefined it's not rendered. Probably a more standard way of detecting this.

from react-bootstrap-typeahead.

ericgio avatar ericgio commented on August 18, 2024 1

Hey @duhmojo, thanks for opening this issue, and for the detailed repro steps and additional investigation. It looks like the flushSync call is coming from react-popper which controls the menu overlay. As far as I can tell, the component is still mounted when setState is called, so it's possible there's some kind of race condition going on.

I plan to drop the react-popper dependency in a future version and the error no longer repros with the update, so I think it's safe to ignore the error for now and it will be resolved going forward, probably in v7.

from react-bootstrap-typeahead.

hanorine avatar hanorine commented on August 18, 2024

@ericgio when would v7 come out? I would like to find a way to resolve this issue. Will ignore the warning for now. Thank you for your time.

from react-bootstrap-typeahead.

duhmojo avatar duhmojo commented on August 18, 2024

I'm going to comment on this issue with my work around. I ignored this for months then had to come back to it.

I was able to set a ref for Typeahead, then onBlur get the ref and call hideMenu() to force the menu closed before anything else in the React lifecycle could execute.

                                            this.searchRefs[field.name] = React.createRef();
                                            return (
                                                <Col key={index}>
                                                    <FormGroup>
                                                        <Form.Label>
                                                            {field.label}
                                                        </Form.Label>
                                                        <Typeahead
                                                            ref={this.searchRefs[field.name]}
                                                            onBlur={(e) => {
                                                                if (this.searchRefs[field.name] !== undefined) {
                                                                    this.searchRefs[field.name].current.hideMenu();
                                                                }
                                                            }}

I will say that hideMenu was no where in the docs, but was in the reference object and code.

from react-bootstrap-typeahead.

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.