Hi I have issue i cann't find the way how to change my component and send props to it. Actually I have Route in app.js like this:
....
<Switch id="main-switch" className={'d-flex '}>
<Route exact={true} path="/learning" component={Learning}/>
</Switch>
....
Now in other component I have other modal component inside. In this modal I have Button which should start the learning. Before that i have to get sama data from DB.... Actually I have all datas and last think what i need is to switch component with these data as prop... But... i don't know how to do this...
My method after clicking on startLearning Button
startInteligentLearning(){
const knowledgeIds = this.getIdsOfKnowledges();
const includeLearned = this.state.disabledLearnedExercies;
let data = null;
this.getDataForLearning(knowledgeIds).then((d) => {
data = d;
console.log(data);
console.log(includeLearned);
this.props.history.push({
pathname:"/learning",
state:{
learningData:"data",
learningType:Constants.LEARNING_TYPE.Learning,
includeAlreadyLearned:includeLearned,
}
});
});
}
async getDataForLearning(knowledgeIds){
const startlearnResponse = await fetch('LearningController/StartLearning/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
'UserRoleID': 1,
'LearningType': Constants.LEARNING_TYPE.Learning,
'KnowledgeIds': knowledgeIds,
}),
});
const startLearnRes = await startlearnResponse.json();
if (startlearnResponse.status === 200 && startLearnRes !== null) {
return startLearnRes;
}
}
I tried use props.history in method above but i don't have history in my props... Is there other way how to change ?