This module looks at Inverse Data Flow in React.
The objectives of this module are to provide you with an understanding of:
- Inverse Data Flow
This Learning Path is aimed at all who wish to learn how to use the ReactJS framework.
We welcome all feedback and suggestions - please contact us at email@example.com to let us know what you think.
In the fourth step of thinking in React, we identified that the searchText and the advanced checkbox value are going to be state in the FilterableCoursesTable, as they are both needed in the CourseTable component and the SearchBar component. We're going to round up the code in the application so far before we think about adding any inverse data flow.
You can see that from the code, adding state to the FilterableCoursesTable is a quick and simple job to do. State is added in lines 9 and 10, and pass these props to the two sub-components in lines 14 to 22. From the component viewer in the developer tools, we can see that the SearchBar and the CourseTable both now receive the state as props.
It may seem complicated, but if you take some time to read it through, it's just to set in the logical situations to make sure only the courses the user has requested are displayed. And just to prove that the filtering works, we've set the initial value of searchText to fund so that the course is displayed and only ones with fund in the name and advanced set to false.
The search bar is more complicated because ultimately it needs to be able to provide data, to update the status search texts and advance in its parent component. That's where we're going next. We weren't able to add the on change functionality to the two input elements, and we've got the red warning message on the console. The other warning is telling us that we never used the set state functions in the FilterableCoursesTable. So perhaps that's a clue as to what we need to do next.
Ed is an Outstanding Trainer in Software Development, with a passion for technology and its uses and holding more than 10 years’ experience.
Ed is responsible for delivering QA’s Programming Foundations course using the Eclipse IDE. His skillset extends into the DevOps sphere, where he is able to deliver courses based around Agile/Scrum practices, version control, and CI/CD.