Skip to content

lavcraft/react-hooks-composition-in-webpack-entry-problem-example

Repository files navigation

React hook composite with webpack example

Reproduce problem occurred when compose two react hooks from different webpack entries

How to start

If you have tmux, will run: npm run all:start

Otherwise: npm run sdk:dev and next (in different terminal) npm run ui:dev

And now - open http://localhost:3000

Project structure

  1. sdk - project with webpack package. Contained useful hooks
  2. shared - project with shared code, for sdk an other project (just for example)
  3. ui - main project

Problem explanation

When you open page, you see logs in console with stacktraces:

look at ContextDevices: Object
look at ContextCallManager: Object
look at ContextDevices: undefined
look at ContextDevices: Object
look at ContextCallManager: Object
look at ContextDevices: undefined

Detailed research show, that useDevices throw error only when call from useCall:

export function useCall(): CallApi {
    const manager = useCallManager();
    const devices = useDevices();
...
}

Directed by Robert B. Weide

Problem solving

To be continued...

Related Materials and Discussions

  1. React repo issue
  2. Webpack repo issue
  3. Webpack repo issue 2
  4. Gitter react related thread
  5. Gitter webpack related thread
  6. Telegram conversation in Webpack RU
  7. Stackoverflow question
  8. next.js discussion

About

Reproduce problem with react composite inside different webpack entries

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors