Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7457
Closed
Open
Issue created Aug 01, 2019 by Administrator@rootContributor

Async anonymous function get lost in production

Created by: vince1995

Describe the bug

I have a function which calls an async anonymous function. Everything is fine in development but in production the relevant code is lost.

My code:

    getPOIInformation = (index) => {
        const activePOIObject = pois[this.state.activePOIIndex];
        const properties = activePOIObject.geojson.features[index].properties;
        console.log(properties);

        if (!properties.additionalInformation) {

            properties.additionalInformation = "LOADING";

            (async function () {
                const response = await api.getPoiInformation({ type: properties.osmType, id: properties.id });
                properties.additionalInformation = response;
                this.forceUpdate();
            }).bind(this)();

        }

        return properties.additionalInformation;
    }

Code after run build:

a.getPOIInformation = function (e) {
        var t = qe[a.state.activePOIIndex].geojson.features[e].properties;
        return console.log(t),
            t.additionalInformation || (t.additionalInformation = "LOADING"),
            t.additionalInformation
    }

I think there is something in the webpack/babel configuration wrong.

Assignee
Assign to
Time tracking