** Property context does not exist on type NodeRequire
const customIcons = importAll(require.context('./', false, /\.(png|jpe?g|svg)$/));
FIX:
npm install @types/webpack-env
const customIcons = importAll(require.context('./', false, /\.(png|jpe?g|svg)$/));
npm install @types/webpack-env
export function actionExampleFirst(data: any) { console.log('actionExampleFirst has called. parameters: ' + data); } export function actionExampleSecond(data: any) { console.log('actionExampleSecond has called. parameters: ' + data); }
import React from 'react'; import * as actions from './actions'; interface IProp { } type ActionType = typeof actions; class CallActionsDynamically extends React.PureComponent<IProp> { constructor(props: IProp) { super(props); this.dynamicCall = this.dynamicCall.bind(this); } componentDidMount() { this.dynamicCall('actionExampleSecond', 'some parameters 2'); this.dynamicCall('actionExampleFirst', 'some parameters 1'); } dynamicCall<K extends keyof ActionType>(funcName: K, data: any) { actions[funcName](data); } render() { return( <></> ); } } export default CallActionsDynamically;
actionExampleSecond has called. parameters: some parameters 2 actionExampleFirst has called. parameters: some parameters 1