1

Hi If any one can help. Thanks in advance

In console I am also getting this

index.js:1 Warning: AppBootUp(...): No render method found on the returned component instance: you may have forgotten to define render

enter image description here

this is my App.js

import React from "react";
import AppRoutes from "../routes/routers";
import { createStore } from 'redux'
import rootReducer from '../store/reducers/index'
import {Provider} from "react-redux";

const store = createStore(rootReducer);

export default class AppBootUp extends React.Component<> {

    static render() {
        return (
            <Provider store={store}>
            <AppRoutes/>
            </Provider>
        );
    }
}

this is my AppRoutes

import React from "react";
import { BrowserRouter as Router, Redirect, Route, Switch } from "react-router-dom";
import Login from "../components/Login/login"

const routesConfig = [
    {
        path: "/",
        component: Login,
        name: "Login",
        exact: true
    }
];

const AppRoutes = () => {
    return (
        <Router>
            <Switch>
                {routesConfig.map(config => {
                    return (
                        <Route
                            exact={config.exact && true}
                            key={`${config.name}`}
                            path={config.path}
                            render={(props) => {
                                const ComponentToRender = config.component;
                                return <ComponentToRender {...props} />;
                            }}
                        />
                    );
                })}
                <Redirect to="/" />
            </Switch>
        </Router>
    );
};

export default AppRoutes;;

this is login.js

import React from "react";

export default class Login extends React.Component {

    constructor(props) {
        super(props);
    }

    render() {
        return (
            <div>
                <p>
                   hello
                </p>
            </div>
        );
    }
}

I am using react-router-dom. I think, I am missing something little here.

3 Answers 3

1

Remove static method from render method in AppBootUp class. If you define a render method as static, it won't be available in class instance, which is why you are getting this error.

export default class AppBootUp extends React.Component<> {

    render() {
        return (
            <Provider store={store}>
            <AppRoutes/>
            </Provider>
        );
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

u might need to disable that warning from you IDE config.
1

You need to remove static before render method of AppBootUp.

render shouldn't be a static property of React class component otherwise it won't exist on component's instance and would become unavailable.

As static properties don't exist on class instance but on the Class itself.

Comments

0

Remove static before render in Appboot. render should not be a static property of React class component otherwise it won't exist on component's instance. As static properties don't exist on class instance but on the Class itself.

Normally this happens when you accidentally alt+enter on render in Webstorm. when it shows warning that this method can be static.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.