You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Table extends Component{
constructor(props){ /* some code */ }
componentWillReceiveProps(props){ /* update local state */ }
render(){ /* some JSX */}
}
export default connect(
function stateToProps(){},
function dispatchToProps(){})
(Table);
By SOLID need:
Table.jsx
import React,{Component} from 'react';
import {connect} from 'react-redux';
class Table extends Component{
constructor(props){ /* some code */ }
componentWillReceiveProps(props){ /* update local state */ }
render(){ /* some JSX */}
}
export default Table;
App.jsx
import React,{Component} from 'react';
import {createStore} from 'redux';
import { connect,Provider } from 'react-redux';
//note!!!
import ConnectComponent from './ConnectComponent';
import store from './Store';
import state1 from './states/state1';
import state2 from './states/state2';
import dispatch from './actions/action1';
import Table from './components/Table';
class App extends Component {
render(){
return (
<Provider store={store}>
<>
<!-- note ConnectComponent -> connect !!! -->
<ConnectComponent
state={state1}
dispatch={dispatch}
component={Table}/>
<ConnectComponent
state={state2}
dispatch={dispatch}
component={Table}/>
</>
</Provider>
);
}
}
export default App;
Note!!! connect as component ( this code is not perfect, but i show my way )
ConnectComponent.jsx
import React from 'react';
import {connect} from 'react-redux';
export default function ConnectComponent(props){
let C = connect( props.state,props.dispatch)(props.component);
return (<C/>);
}
For combine mapToState func. and dispath. func need some function, example:
I think, i can propose this feature in other time in TS code and integrate in react-redux, for fix HOC in HOC. If it is true way. But need some time ) What do you say?
The text was updated successfully, but these errors were encountered:
Default case use of connect:
By SOLID need:
Table.jsx
App.jsx
Note!!! connect as component ( this code is not perfect, but i show my way )
ConnectComponent.jsx
For combine mapToState func. and dispath. func need some function, example:
My proposal have one problem - HOC in HOC )
I think, i can propose this feature in other time in TS code and integrate in react-redux, for fix HOC in HOC. If it is true way. But need some time ) What do you say?
The text was updated successfully, but these errors were encountered: