Skip to content

Commit

Permalink
Dispatch action after Stream creation
Browse files Browse the repository at this point in the history
  • Loading branch information
up16 committed Jul 12, 2020
1 parent ecb8d5d commit 528fb0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/actions/apis/streams.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";

export default axios.create({
baseURL: "https://localhost:3002",
baseURL: "http://localhost:3002",
});
3 changes: 2 additions & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export const signOut = () => {
};

export const createStream = (formValues) => async (dispatch) => {
streams.post("/streams", formValues);
const response = await streams.post("/streams", formValues);
dispatch({ type: "CREATE_STREAM", payload: response.data });
};
16 changes: 12 additions & 4 deletions src/components/streams/StreamCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class StreamCreate extends React.Component {
);
};

onSubmit(formValues) {
console.log(formValues);
onSubmit = (formValues) => {
//console.log(formValues);
//formValues.preventDefault();
}
this.props.createStream(formValues);
};
render() {
//console.log(this.props);
return (
Expand Down Expand Up @@ -66,7 +67,14 @@ const validate = (formValues) => {
return errors;
};

export default reduxForm({
// export default reduxForm({
// form: "streamCreate",
// validate,
// })(StreamCreate);

const formWrapped = reduxForm({
form: "streamCreate",
validate,
})(StreamCreate);

export default connect(null, { createStream })(formWrapped);
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import App from "./components/App";
import { Provider } from "react-redux";
import { createStore, applyMiddleware, compose } from "redux";
import reducers from "./reducers";
import reduxThunk from "redux-thunk";

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers, composeEnhancers(applyMiddleware()));
const store = createStore(
reducers,
composeEnhancers(applyMiddleware(reduxThunk))
);

ReactDOM.render(
<Provider store={store}>
Expand Down

0 comments on commit 528fb0b

Please sign in to comment.