danielr18 / connected-next-router

A Redux binding for Next.js Router compatible with Next.js.
MIT License
109 stars 30 forks source link

V2 Refactor - Typescript support #24

Closed danielr18 closed 4 years ago

danielr18 commented 5 years ago

Env vars are never booleans. You do Boolean(process.env.MY_BOOL || 'false'):

  • MY_BOOL='' => Boolean('' || 'false') => Boolean('false')
  • MY_BOOL=null => Boolean('false')
  • typeof MY_BOOL === 'undefined' => Boolean('false')
  • MY_BOOL='false' => Boolean('false')
  • MY_BOOL='true' => Boolean('true')

The thing is that process.env.__NEXT_EXPORT_TRAILING_SLASH is replaced by webpack's DefinePlugin, the end result is something like:

 external_react_default.a.createElement(connected_next_router["ConnectedRouter"], {
        exportTrailingSlash: false
      }, external_react_default.a.createElement(Component, pageProps))));
    }
return s.a.createElement(
  c.Container,
  null,
  s.a.createElement(
    f.a,
    { store: r },
    s.a.createElement(O.a, { exportTrailingSlash: !1 }, s.a.createElement(e, n))
  )
)

So it's actually not going to be a string in the built code, that's why I didn't convert it to a boolean. Thoughts?

haf commented 5 years ago

Nice work!