Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

react-router4, bundler-loader and typescript problem #58

@DebugIsFalse

Description

@DebugIsFalse

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;
}

}`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions