Closed hitochan777 closed 6 years ago
I understand your problem and I think that the solution of returning a promise with initSessionService
is the best one. Feel free to open a PR to solve this.
Another workaround could be using the variable checked
in the Redux store (I think this variable is not documented, my bad :-1: ).
Try something like this:
sessionService.initSessionService(store, {driver: 'COOKIES'} );
render(
<Provider store={store}>
{checked && <App />}
</Provider>,
document.getElementById('root')
)
Anyway, your solution is much better(with a Promise). Thanks!
@bernabe9 OK! I will work on that!
Fixed #18
Hi. Thans for your great work! I am currently facing an issue of components trying to access
session.user
before it is ready to be accessed. The problem is thatinitSessionService
callsloadUser
in an async manner ( which is perfectly fine), thus,session.user
can be accessed when it is not ready.An example code is show below (Note that unimportant codes are abbreviated).
index.js
App.js
To avoid this problem, I want to make sure that
session.user
is set before proceeding to the next lines. One way to achieve this is to return Promise ininitSessionService
and modifyrefreshFromLocalStorage
a bit (so that it returns the promise that corresponds toloadUser
).If you have another way of solving this issue, please let me know. Otherwise, I am willing to issue an PR! Thanks!