In this lesson we'll add a footer text item to show the total count of what is in the current filtered view. We'll show the technique of deriving computed values in render functions.
We'll start by rendering a text component. We'll say this.props.count, and then type the text count. If we refresh, you can see that no count is rendering. We'll switch back to our app, scroll down to our footer, pass in count=filter items active, because we want to filter for the active items.
We'll pass in this.state.items. Then we will get the length of that. Now that we have the length being passed down, we can refresh, and see that we have a count of zero. We can add an item, which will then increase our count. If we toggle it to complete, it'll drop our count to zero.
You must be a Pro Member to view code
Access all courses and lessons, track your progress, gain confidence and expertise.