Making life easy with React View Controller
Adding Controller to the party of Components, Containers, Actions, Reducers…
Have you ever feel like life cycle methods in react components is kind of poluting the component and also increasing the file size? Well, in our project we also come across such scenarios and we thought of doing something about it.
We came up with a solution: we created an open source library(react-view-controller), which delegates all the life cycle methods to Controller making View as dumb as possible. All the logic is contained in the controller. Event handling is also taken care by the controller.
- Spliting component files on basis of single responsibility.
- View will only worry about rendering while the Controller will take care of providing the data and handling the events.
- Better and easier code maintenance.
- TDD becomes easy. Unit testing Components is super simple.
We are using this pattern in our projects and are absolutely loving it.
- Why Controller is needed?
- How Controller solves the problem
- Using open source library
- Integration with Redux, other Higher Order Components
- Testing component and controller
Participants should have knowledge of React and a little bit of typescript.
I am software developer in ThoughtWorks with 6 years of experience.
I have worked on various technologies, starting with Java, Android; then moved to Html, CSS, JS, Typescript, React.
Once I entered JS world, I never went back. Absolutely in love with JS.