I'm creating files to learn react myself. To simplify things I use cdn and everything went flowless till now. I can't figure out how to provide the redux-logger middleware to my Redux.applymiddleware fn.
What should I replace the /* logger here */ string with ?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React step by step</title>
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/redux@4.0.1/dist/redux.js" crossorigin></script>
<script src="https://unpkg.com/redux-thunk@2.1.0/dist/redux-thunk.js" crossorigin></script>
<script src="https://unpkg.com/redux-logger@3.0.6/dist/redux-logger.js" crossorigin></script>
<script type="text/javascript" src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
</head>
<body>
<div>Open your Dev tool! (F12)</div>
</body>
<script type="text/babel" >
const reducer = (state = {}, action) => {
return state;
}
//const myMiddleware = Redux.applyMiddleware( /* logger here */)
const store = Redux.createStore( reducer/*, myMiddleware*/ );
store.dispatch({ type: 'FOO'});
const currentState = store.getState();
console.log(currentState)
</script>
</html>
If you check redux-logger
's UMD bundler config, which is in their GitHub repo: https://github.com/LogRocket/redux-logger/blob/master/rollup.config.js#L33 - you'll see that they named the module for the UMD bundle as reduxLogger
. So you should access it as follows:
const logger = window.reduxLogger.logger