drcmda / react-contextual

🚀 react-contextual is a small (less than 1KB) helper around React 16s new context api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typo on context check

msssk opened this issue · comments

Lines 61-62 in store.js don't seem to make sense:

if (!store)
  this.store.context = id ? createNamedContext(id) : ProviderContext

Should 61 be changed?

if (!store.context)
commented

looks good to me, if no external store is passed a context is created either by id or the default.

Looks good indeed; The issue just needs a little more context.

https://github.com/drcmda/react-contextual/blob/2f4bec2f5fc3bd58bc044f1739b73f7b63407b86/src/store.js#L58:L62

store can still be undefined here, but this.store has been initialized one line before the if. Because there was no store provided to the contructor, the next thing to do is, assign this store a new context. Its like @drcmda writes, either done with createNamedContext or ProviderContext depending on the given arguments (id).