Coder Social home page Coder Social logo

Comments (6)

receptiryaki avatar receptiryaki commented on May 5, 2024 1

@cuongdevjs you need to use <Route render={routeProps => <Comp {...routeProps} />} /> instead of <Route component={<Comp />} />

https://reacttraining.com/react-router/web/api/Route/render-func

from react-boilerplate-cra-template.

cuongdevjs avatar cuongdevjs commented on May 5, 2024

I think update version of react to 16.13.1 will resolve this problem.
redux-form/redux-form#4619 (comment)

from react-boilerplate-cra-template.

Can-Sahin avatar Can-Sahin commented on May 5, 2024

I cannot get this error while switching routes. What exactly did you do?

from react-boilerplate-cra-template.

cuongdevjs avatar cuongdevjs commented on May 5, 2024

This is my code. I think it has a problem with logic

import { HomePage } from 'app/containers/HomePage/Loadable';
import { LoginPage } from 'app/containers/LoginPage/Loadable';
import { NotFoundPage } from 'app/components/NotFoundPage/Loadable';
import { Header } from 'app/components/Header/Loadable';
import { WelcomePage } from 'app/components/WelcomePage/Loadable';

interface Props {}

export const App = memo((props: Props) => {
  useInjectReducer({ key: sliceKey, reducer: reducer });
  useInjectSaga({ key: sliceKey, saga: appSaga });

  const isLogged = useSelector(selectIsLogged);
  const infoUser = useSelector(selectInfoUser);
  const dispatch = useDispatch();

  React.useEffect(() => {
    if (token)
      !isLogged
        ? dispatch(actions.changeIsLogged(true))
        : dispatch(actions.setInfoUser({ avatar, name }));
    else {
      clearAllLS();
      dispatch(actions.changeIsLogged(false));
    }
  }, [dispatch, isLogged]);

  const routeOnlyUser = comp => {
    const token = getItem('meeting-token');
    return token ? comp : redirect('/welcomePage');
  };

  const routeOnlyGuest = comp => {
    const token = getItem('meeting-token');
    return !token ? comp : redirect('/');
  };

  return (
    <AppWrapper>
      <MainWrapper>
        <Switch>
          <Route exact path="/" component={routeOnlyUser(HomePage)} />
          <Route path="/welcomePage" component={routeOnlyGuest(WelcomePage)} />
          <Route path="/signIn" component={routeOnlyGuest(LoginPage)} />
          <Route path="/signUp" component={routeOnlyUser(LoginPage)} />
          <Route component={NotFoundPage} />
        </Switch>
      </MainWrapper>
      <GlobalStyle />
    </AppWrapper>
  );
});

from react-boilerplate-cra-template.

cuongdevjs avatar cuongdevjs commented on May 5, 2024

facebook/react#18178 (comment)
I was check stack error, this error probably due to useSelector hook :)

from react-boilerplate-cra-template.

Can-Sahin avatar Can-Sahin commented on May 5, 2024

well its really an ongoing discussion with no clear reasons. I dont see this error though. Probably related to your setup. If you can find out what the error is and where it originates from let us know with PR

from react-boilerplate-cra-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.