This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSelector } from 'reselect' | |
// supports passing in the whole obj or just the string to correct the video type | |
const fixVideoTypeNaming = (videoType) => { | |
let video = videoType | |
// If video is a video object | |
if (video && typeof video === 'object') { | |
const media = { ...video } | |
video = media.videoType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withTotalCount = (WrappedComponent) => { | |
class WithTotalCountContainer extends React.Component { | |
componentDidMount = () => { | |
const { total, dispatch } = this.props | |
if (total == null) { | |
dispatch(fetchTotalVideoTypeCount()) | |
} | |
} | |
render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TotalVideoCount = ({ classes, total, fetching, fetchError }) => { | |
if (fetching) return <LoadingSpinner /> | |
const hasResults = !!total | |
const noResults = fetched && !total | |
const errorOccurred = !!fetchError | |
return ( | |
<Typography | |
variant="h3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getOverallSelector = (state) => | |
state.app[fixVideoTypeNaming(state.app.media.video.videoType)].options.total | |
.overall | |
export const getSpecificWeekSelector = (state, props) => | |
state.app[fixVideoTypeNaming(state.app.media.video.videoType)].options.weekly[ | |
props.date | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SomeComponent = ({ children, items = {}, isVisible }) => ( | |
<div> | |
{Object.keys(items).length ? ( | |
<DataTable items={items} /> | |
) : ( | |
<h2>Data has not been received</h2> | |
)} | |
</div> | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"TypeError: Cannot convert undefined or null to object | |
at Function.keys (<anonymous>) | |
at yazeyafabu.js:4:45 | |
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:13924 | |
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:10866" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
const { arr } = this.props | |
return ( | |
<div> | |
{arr && arr.map()...} | |
</div> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const api = { | |
async getTotalFrogs() { | |
return { | |
data: { | |
result: [ | |
{ name: 'bob the frog', tongueWidth: 50, weight: 8 }, | |
{ name: 'joe the other frog', tongueWidth: 40, weight: 5 }, | |
{ name: 'kelly the last frog', tongueWidth: 20, weight: 2 }, | |
], | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const api = { | |
async getTotalFrogs() { | |
return { | |
data: { | |
result: [ | |
{ name: 'bob the frog', tongueWidth: 50, weight: 8 }, | |
{ name: 'joe the other frog', tongueWidth: 40, weight: 5 }, | |
{ name: 'kelly the last frog', tongueWidth: 20, weight: 2 }, | |
], | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const api = { | |
async getTotalFrogs() { | |
return { | |
data: { | |
result: [ | |
{ name: 'bob the frog', tongueWidth: 50, weight: 8 }, | |
undefined, | |
{ name: 'kelly the last frog', tongueWidth: 20, weight: 2 }, | |
], | |
}, |