Axe ios Ожидание программы сваливания - PullRequest
0 голосов
/ 01 марта 2020

У меня есть функция asyn c в моем приложении. js файл (ниже) плагина Yeoman Generator PowerPoint, где я использую следующую строку:

let response = await axios.get('http://127.0.0.1:5000/crop/i');

В версии файла в моем репозитории я изолировал, что эта строка не позволяет моей программе продолжать выполнение, и я не уверен, почему это происходит. Если я закомментирую строку, все работает нормально, но попытка использовать проанализированный JSON для замены строки «Hello world» ниже или даже оставив там строку Ax ios, не дает ей нормально работать. Я все делаю правильно, поэтому мне было интересно, существует ли очень техническое соглашение по архитектуре js / реакции, которое мне не хватает?

Ссылка на зеркало GitHub для приложения. js file

// App.js
import * as React from "react";
import { Button, ButtonType } from "office-ui-fabric-react";
import Header from "./Header";
import HeroList, { HeroListItem } from "./HeroList";
import Progress from "./Progress";
import { element } from "prop-types";
const axios = require('axios');
/* global Button, console, Header, HeroList, HeroListItem, Office, Progress */

export default class App extends React.Component {
  constructor(props, context) {
    super(props, context);
    this.state = {
      listItems: []
    };
  }

  componentDidMount() {
    this.setState({
      listItems: [
        {
          icon: "Ribbon",
          primaryText: "Achieve more with Office integration"
        },
        {
          icon: "Unlock",
          primaryText: "Unlock features and functionality"
        },
        {
          icon: "Design",
          primaryText: "Create and visualize like a pro"
        }
      ]
    });
  }

  click = async () => {

    /*Cropping Code*/  
    /**
     *
     * THIS LINE STALLS MY CODE
     *
     */
    let response = await axios.get('http://127.0.0.1:5000/crop/i'); //maybe just the route?
    //response.data['text']

    Office.context.document.setSelectedDataAsync(
      "Hello World!",
      {
        coercionType: Office.CoercionType.Text
      },
      result => {
        if (result.status === Office.AsyncResultStatus.Failed) {
          console.error(result.error.message);
        }
      }
    );
  };

  render() {
    const { title, isOfficeInitialized } = this.props;

    if (!isOfficeInitialized) {
      return (
        <Progress title={title} logo="assets/logo-filled.png" message="Please sideload your addin to see app body." />
      );
    }

    return (
      <div className="ms-welcome">
        <Header logo="assets/logo-filled.png" title={this.props.title} message="Welcome" />
        <HeroList message="Discover what Office Add-ins can do for you today!" items={this.state.listItems}>
          <p className="ms-font-l">
            Modify the source files, then click <b>Run</b>.
          </p>
          <Button
            className="ms-welcome__action"
            buttonType={ButtonType.hero}
            iconProps={{ iconName: "ChevronRight" }}
            onClick={this.click}
          >
            Run
          </Button>
        </HeroList>
      </div>
    );
  }
}
...