In this lesson, we’ll create a Link component that manipulates the browser’s address bar using the history API’s pushState method.
The following link in the Link.js:
history.pushState(null, '', this.props.to)
results in a compile error in the latest version of react:
Failed to compile ./src/components/router/Link.js Line 6: Unexpected use of 'history' no-restricted-globals
Search for the keywords to learn more about each error.
Thanks for pointing this out. This is a linting error caused by some updated lint config. You should be able to get everything working again by referencing
history directly from
window.history. You could also disable linting for that line by adding
// eslint-disable-line to the end of the offending line.
Hope this helps.
Yay it works. Thanks for the prompt response! :-)
Glad that cleared it up! :)
Line 7: Unexpected use of 'history' no-restricted-globals
@Dev change "history" to "window.history"; because you don't declare
history, in strict mode, all vars must be declared first.
The code in codesandbox is not working... kindly fix it...