The state gets passed in via props (selectedCategory). Using axios to get an array... it comes back, I can console.log it within the function. I'd like to assign it to a variable and then outside of the function I'd like to map over it. But it is unavailable (undefined)
import React from 'react';
import SearchCategoryMembers from '../libs/category-members';
import MemberItem from './member_item';
const Members = ({ selectedCategory }) => {
if (!selectedCategory) {
return <div className="none" />;
}
SearchCategoryMembers({ categoryTitle: selectedCategory.title }, members => {
console.log(members);
});
// members not available to map over outside of function
return <ul className="member-list" />;
};
export default Members;
members not available to map over outside of function- well, why not map over it inside the function