Я создаю страницу входа с ключом API в ReactionJS.Пользователь должен ввести ключ API, чтобы войти в систему.
проблема в том, что я отправил ключ API, введенный в дочерний компонент, в качестве реквизита.А для тестирования я попытался API-ключом console.log в дочернем компоненте.но я получаю неопределенный.
подосновный функциональный компонент
{
props.login?<div><h1>Login:{props.login}</h1><Fetchapi apiID ={apiID}/></div>: <div className="mbox">
<h3>{props.message}</h3>
</div>
}```
child component(very bid showing necessary part)
```class Fetchapi extends Component {
constructor(props) {
super(props);
this.state = {
datas:[],
more_leads:true,
show:false, // for modal toggling
currentPage:1,
rowsPerPage:10,
clickedData:{
"First Name":"",
"Last Name":"",
"Email":"",
"ID":"",
"Country":"",
"Mobile":""
}
};
this.handleNext = this.handleNext.bind(this);
this.handlePrevious = this.handlePrevious.bind(this);
this.handleShow = this.handleShow.bind(this);
this.handleShow = this.handleShow.bind(this);
// Modal Funtions
}
and many more codes
-
-
-
componentDidUpdate() {
fetch(req)
.then(response=> response.json())
.then(users => {
if(this._isMounted)
{
this.setState({ datas: users.response,
more_leads:users.is_more_leads_available
})
}
});
console.log("apiID from fetch",this.props.apiID) ;// this code gives undefined in console.log
}
I even tried to render in the DOM
```<h1>{this.props.apiID}</h1>```