1
votes

I am trying to launch the SimpleWebRTC app from here: https://docs.simplewebrtc.com/#/?id=getting-started

App.js file:

import React from "react";
import { Provider } from "react-redux";
import ReduxToastr from "react-redux-toastr";
import store from "./redux/store/index";
import Routes from "./routes/Routes";

const App = () => (
  <Provider store={store}>
    <Routes />
    <ReduxToastr
      timeOut={5000}
      newestOnTop={true}
      position="top-right"
      transitionIn="fadeIn"
      transitionOut="fadeOut"
      progressBar
      closeOnToastrClick
    />
  </Provider>
);

export default App;

./redux/store/index.js file:

import { combineReducers } from "redux";

import sidebar from "./sidebarReducers";
import layout from "./layoutReducer";
import theme from "./themeReducer";
import app from "./appReducer";
import auth from "./authReducer";
import { reducer as simplewebrtc } from '@andyet/simplewebrtc';
import { reducer as toastr } from "react-redux-toastr";

export default combineReducers({
  sidebar,
  layout,
  theme,
  toastr,
  app,
  auth,
  simplewebrtc
});

./redux/store/index.js file:

import { createStore, applyMiddleware } from "redux";
import thunk from 'redux-thunk';
import rootReducer from "../reducers/index";

const persistedState = localStorage.getItem('reduxState') ? JSON.parse(localStorage.getItem('reduxState')) : {}

var store

if(persistedState.app){
    store = createStore(rootReducer, persistedState, applyMiddleware(thunk));
}else{  
    store = createStore(rootReducer, applyMiddleware(thunk));
}

store.subscribe(()=>{
    localStorage.setItem('reduxState', JSON.stringify(store.getState()))
})


export default store;

Chat.js file:


const API_KEY = '';
const ROOM_PASSWORD = 'test';
const CONFIG_URL = `https://api.simplewebrtc.com/config/guest/${API_KEY}`
const ROOM_NAME = 'uniq-room-name'

class _SimpleWebRtc extends React.Component {

  constructor(props) {
    super(props);
  }

  render(){


    return (
        <SWRTC.Provider configUrl={CONFIG_URL}>      {/* <------- problem here */}
          {/* Render based on the connection state */}
          <SWRTC.Connecting>
            <h1>Connecting...</h1>
          </SWRTC.Connecting>

          <SWRTC.Connected>
            <h1>Connected!</h1>

            <SWRTC.RequestUserMedia audio auto />

            <SWRTC.Room name={ROOM_NAME} password={ROOM_PASSWORD}>
              <SWRTC.RemoteAudioPlayer />
            </SWRTC.Room>

          </SWRTC.Connected>
        </SWRTC.Provider>
    )
  }
}

const SimpleWebRtc = connect(store => ({simplewebrtc: store.simplewebrtc})) (_SimpleWebRtc)

When I trying run this code it returns a folloowing error for me:

app.js:58464 Uncaught Invariant Violation: Could not find "store" in either the context or props of "Connect(Provider)". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(Provider)".

Do you have any ideas about what is wrong with this code and how to solve this issue?

1

1 Answers

1
votes

I also faced this problem and solved the issue by updating the packages. You have to use

  • react@^16.8.4
  • react-dom@^16.8.4
  • react-redux@^7.0.0
  • redux@^4.0.0
  • redux-thunk@^2.3.0

Here are the requirements for simplewebRTC

https://docs.simplewebrtc.com/#/ReactVersions