This file contains 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
// SimpleBarChart.tsx | |
export const SimpleBarChart: React.FC<IProps> = (props) => { | |
const chartData = useMemo(() => generateSimpleBarChart(), []); | |
return ( | |
<AnyChartReact | |
charts={chartData.charts} | |
credits={false} | |
instance={chartData.stage} | |
legend={true} |
This file contains 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
// next.config.js | |
module.exports = withPlugins( | |
[], | |
{ | |
webpack(config) { | |
config.externals = [...config.externals, { anychart: 'anychart' }]; | |
return config; | |
}, | |
} |
This file contains 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 PortalOut = (props) => { | |
const { portalMap } = useContext(PortalContext); | |
return portalMap.get(props.portalType) || null; | |
}; |
This file contains 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 PortalIn = (props) => { | |
const { addPortalItem, removePortalItem } = useContext(PortalContext); | |
useEffect(() => { | |
addPortalItem(props.portalType, props.children); | |
return () => removePortalItem(props.portalType); | |
}, [props.portalType, props.children]); | |
return null; |
This file contains 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 PortalContext = React.createContext(null); | |
export const PortalProvider = (props) => { | |
const [portalMap, setPortalMap] = useState(new Map()); | |
const addPortalItem = useCallback((portalType, component) => { | |
portalMap.set(portalType, component); | |
const clonedMapWithNewItem = new Map(portalMap); |
This file contains 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
/** | |
* @param {string} url - The source image | |
* @param {number} aspectRatio - The aspect ratio | |
* @return {Promise<HTMLCanvasElement>} A Promise that resolves with the resulting image as a canvas element | |
*/ | |
function crop(url, aspectRatio) { | |
// we return a Promise that gets resolved with our canvas element | |
return new Promise(resolve => { |
This file contains 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 dictionary = {}; | |
// Add keys to the dictionary | |
dictionary['REQUEST_SHOW_FINISHED'] = (state, payload) => { | |
return { | |
...state, | |
show: payload, | |
} | |
}; | |
dictionary['REQUEST_EPISODES_FINISHED'] = (state, payload) => { | |
return { |
This file contains 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 initialState = { | |
currentShowId: '74', | |
show: null, | |
episodes: [], | |
actors: [], | |
}; | |
export const showsReducer = baseReducer(initialState, { | |
[ShowsAction.REQUEST_SHOW_FINISHED](state, action) { | |
return { |
This file contains 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
switch (action.type) { | |
case ShowsAction.REQUEST_SHOW_FINISHED: | |
return { | |
...state, | |
show: action.payload, | |
}; | |
case ShowsAction.REQUEST_EPISODES_FINISHED: | |
return { | |
...state, | |
episodes: action.payload, |
This file contains 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 default function ToastCard(props) { | |
const dispatch = useDispatch(); | |
const onClickRemoveNotification = useCallback( | |
(event, data) => { | |
dispatch(ToastsAction.removeById(props.item.id)); | |
}, | |
[dispatch, props.item.id] | |
); |