No soy usuario lo que está causando el problema. Cuando ingreso un ticker en la barra de búsqueda, por ejemplo, FB , los datos solo representan la mitad de la información, pero no el modelo de calculationModel y la función de addingYear año en el componenteDidUpdate, a menos que vuelva a ingresar la variable de entrada nuevamente en la barra de búsqueda para obtener toda la información que se muestra cómo se supone que tengo que alquilar el mismo ticker o cualquier otro cada vez para que la información se muestre correctamente y tengo que seguir los mismos pasos cuando actualizo la página.
Así es como se ve mi componente:
constructor(props) { super(props); this.state = { ticker: "", reportDate: "", subkey: "", FCF: "", year: "", futureCashFlows: "", npv: "", terminalValue: "", totalPresentValue: "", addYear1: "", addYear2: "", addYear3: "", addYear4: "", addYear5: "" }; } applyData(data) { this.setState({ reportDate: data.reportDate, subkey: data.subkey, commonShares: data.commonShares, year: data.reportDate.slice(0, 4) }); } CalulationModel() { const DCF_Calulation = calculate( this.state.FCF, [this.props.growthRate], this.props.peRate, this.props.discouted, 2 ); this.setState({ futureCashFlows: DCF_Calulation.futureCashFlows.slice(1, 6), totalPresentValue: DCF_Calulation.totalPresentValue, npv: Math.pow(1 + this.props.discoutedRate, 5) }); } printState() { console.log("New state AFTER update"); console.log(this.state); } addingYear() { // const myDate = moment(this.state.reportDate, "YYYY-MM-DD"); const myDate = moment(this.state.year, "YYYY"); this.setState( { addYear1: myDate.add(1, "y").format("YYYY"), // 2022 addYear2: myDate.add(1, "y").format("YYYY"), // 2023 addYear3: myDate.add(1, "y").format("YYYY"), // 2024 addYear4: myDate.add(1, "y").format("YYYY"), // 2025 addYear5: myDate.add(1, "y").format("YYYY") // 2026 }, this.printState ); } componentDidUpdate(prevState) { if (this.props.ticker !== prevState.ticker) { stockFinancial.stockPulledData( this.props.ticker, this.applyData.bind(this) ); this.CalulationModel(); this.addingYear(); } }