CrocoDillon / universal-react-redux-boilerplate

Step by step creation of a Universal React + Redux Boilerplate
Other
176 stars 33 forks source link

What signature is this? Works well in WP compiled code and throws error Devtools console #20

Closed wzup closed 7 years ago

wzup commented 7 years ago

What does colon mean here? Can't find info about it. From here https://github.com/CrocoDillon/universal-react-redux-boilerplate/blob/master/src/routes.js#L38

const configureRoutes = (store: Object) => {

Webpack compiles it as a plain vanilla function:

const x = (store: Object, set: Array) => { console.log(store, set) }

// After Webpack
    var x = function x(store, set) {
        console.log(store, set);
    };

But Chrome throws error:

Uncaught SyntaxError: Unexpected token :
CrocoDillon commented 7 years ago

It's a Flowtype thing, the React Babel preset includes a plugin to remove it. I'm not totally convinced by Flowtype yet but I believe it will be good to have your setup at least ready for it.