I'am struggling to find a quick solution to my problem , because clients are complaining about that the Site cannot be rendered on the IE . I have done a little research and i came across this react-app-polyfill/ie11
.
I have insert it as an entry point on mine src/index.js
It have worked i saw my project ( only the login tho ) working on IE 11 , but after the login it is redirected again back to the login page . The error that IE throws back is :
DOM7011 : The code on this page disabled back and forward caching.
Unhandled promise rejection TypeError: Unable to get property 'data' of undefined or null reference
After a while i came also across this : https://reactjs.org/docs/javascript-environment-requirements.html
The new JavaScript Environment Requirements . Bassicly they suggest to enable as an entry point on your index.js
this
import 'core-js/es/map';
import 'core-js/es/set';
So far i have no clue what is going on , but still the app is not running properly on IE . Can somebody give me some advice what to do ?
UPDATED Login.js
export default class Login extends Component {
constructor(props) {
super(props);
this.state = {
translations: EN_TRANSLATIONS,
clientNumber: "",
password: "",
redirectToReferrer: '',
loginErrorMessage: "",
lockedUntilDate: ''
};
}
async componentWillMount() {
let tenant = window.location.hostname
axios.post(SERVER_URL + '/api/user/page', {
tenant: tenant
})
.then(response => {
localStorage.setItem('page', JSON.stringify(response.data.branding));
localStorage.setItem('tenant', tenant);
this.setState({
branding: response.data.branding,
tenant: tenant,
pageReady: true
});
});
login = () => {
axios.post(SERVER_URL + '/api/user/access', {
tenant: this.state.tenant,
customerNumber: parseInt(this.state.clientNumber),
password: sha1(this.state.password + FE_SALT)
})
.then(response => {
localStorage.setItem('token', response.data.token);
localStorage.setItem('access', JSON.stringify(response.data.branding));
this.setState({
branding: response.data.branding,
accessReady: true
});
if (this.state.accessReady) {
if (response.data.passwordValidity >= 0) {
Auth.authenticate(response => {
this.setState({ redirectToReferrer: 'dashboard' })
});
} else {
Auth.authenticate(response => {
this.setState({ redirectToReferrer: 'changePassword' })
});
}
}
})
``
index.js
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/jsdom';
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import { BrowserRouter } from "react-router-dom";
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById("root")
);
Also i marked that i cannot import 'react-app-polyfill/stable'
i think this should work , but i am not sure .
UPDATE
I have deleted the node_modules
and installed again react-app-polyfill
. Now the 'react-app-polyfill/stable'
is recognized , but i ran into another error .
SCRIPT438: Object doesn't support property or method 'repeat'
... This IE is making me crazy ...
UPDATE
Okey so i was able to delete my private routes and make every route after the login visible <Route/>
. If i hardcode the URL path and disable the security i can get access to my dashboard page . So that gives me thinking that the problem is coming from the <Redirect/>
component . Because he is the only one standing between the login and the dashboard . Any suggestion why is this conflict between IE
and <Redirect/>
???