Mastermindzh / react-cookie-consent

A small, simple and customizable cookie consent bar for use in React applications.
https://mastermindzh.github.io/react-cookie-consent/
MIT License
610 stars 84 forks source link

Cookie consent doesn`t work on .html pages #105

Closed Ghaleb-alnakhlani closed 3 years ago

Ghaleb-alnakhlani commented 3 years ago

Hi I have multiple routes in my React application most of them looks like below, these HTML pages are placed in public folder

<Route exact path="/" render={() => {window.location.href="Home.html"}} /> <Route path="/quiz" component={App} /> <Route path="/questions" render={() => {window.location.href="questions.html"}} /> <Route path="/profile" render={() => {window.location.href="profile.html"}} /> <Route path="/about" render={() => {window.location.href="about.html"}} /> It only display on the component App.js and not the other HTML pages

Please any suggestion on how to solve that?

Mastermindzh commented 3 years ago

This is the expected behaviour. You are not loading the pages as PART of your react app, you're redirecting to HTML pages (thus removing any control React has)

I usually use react-router to route pages :) This stack overflow answer handles multiple pages in React nicely.

Good luck!