S
S
sergeyviktorovich2021-10-30 10:48:40
React
sergeyviktorovich, 2021-10-30 10:48:40

Why don't links become active when using connect(mapStateToProps)(TaskMain)?

did like this, but now the url is changing and the components of this url are not substituted, what did you do wrong?

import { routerReducer } from 'react-router-redux';

let combinedReducer = combineReducers({
  // редьюсер countersReducer отвечает за раздел state под именем counters
  stateTaskLists: TaskReducer,
  routing: routerReducer
  // + другие редьюсеры
});

export default combinedReducer;




import TaskMain from './page/MainPage.js';
import combinedReducer from "./stores/stores.js";
import { syncHistoryWithStore } from 'react-router-redux';
import { Router } from 'react-router-dom';
import { createBrowserHistory } from 'history';

const store = createStore(combinedReducer);
export default store;
let history = syncHistoryWithStore(createBrowserHistory(), store);

ReactDOM.render(<Provider store={store}><Router history={history} ><TaskMain /></Router></Provider>, document.getElementById('root'));


then changed this line like this
ReactDOM.render(<Provider store={store}><TaskMain history={history} /></Provider>, document.getElementById('root'));


tried like this but BrowserRouter doesn't support history <BrowserRouter history={this.props.history}>

and change url like this but components don't change<Router history={this.props.history}>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Matyushkin, 2021-10-30
@sergeyviktorovich

Your project
1) The obsolete react-router-redax has been cut out
2) The export of the MenuTask and TaskMain components has been changed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question