Skip to content

Instantly share code, notes, and snippets.

@athulmurali
Last active June 3, 2019 15:37
Show Gist options
  • Save athulmurali/19c106afa7cd449584abe19cb2f49e98 to your computer and use it in GitHub Desktop.
Save athulmurali/19c106afa7cd449584abe19cb2f49e98 to your computer and use it in GitHub Desktop.
Selection fix
//Note: some may have selectedWidget, some may not , ignore it if it is not yours.
// while selecting a module, set topic and selectedWidget to null so that you don't retain the existing selection
// while selecting a lesson, set widget and selectedWidget to null
// This is just a sample code
this.state={
// ...
selectedModule: course.modules[0],
selectedLesson: course.modules[0].lessons[0],
selectedTopic: course.modules[0].lessons[0].topics[0]
// ...
}
// To handle  the issue, 
// replace that code and initialize with 
{
selectedModule: null
selectedLesson: null
selectedTopic: null
}
render(){
return <div>
{this.state.selectedModule && <LessonList>}
{this.state.selectedLesson && <TopicList>}
{this.state.selectedTopic && <WidgetList>}
<div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment