This repository was archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
react-router4, bundler-loader and typescript problem #58
Copy link
Copy link
Open
Labels
Description
when i use typescript
i set webpack module loaders
{ test : /\.tsx?$/, include: path.resolve(__dirname, './src/router/'), loaders : ['bundle-loader?lazy', 'babel-loader','ts-loader'] }
and it will show me the error 'props.load is not a function';
App.tsx
`import 'babel-polyfill';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import {
HashRouter,
Route
} from 'react-router-dom';
import Bundle from './bundle';
import HomeIndex from './router/homes/home';
const Home = () => (
{
(Home : any) =>
}
);
ReactDOM.render(
welcome to react
,document.getElementById('root')
);
`
Bundle.tsx
`import * as React from 'react';
export default class Bundle extends React.Component< any,any > {
constructor( props?:any ) {
super(props);
this.state = {
mod : null
}
}
componentWillMount() {
this.load(this.props)
}
componentWillReceiveProps( nextProps : any ) {
if (nextProps.load !== this.props.load) {
this.load(nextProps)
}
}
load( props:any) {
this.setState({
mod: null
});
props.load(( mod :any ) => {
this.setState({
mod: mod.default ? mod.default : mod
});
});
}
render() {
return this.state.mod ? this.props.children(this.state.mod) : null;
}
}`