Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update form handler example #11059

Merged
merged 1 commit into from Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 0 additions & 37 deletions examples/form-handler/components/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions examples/form-handler/package.json
Expand Up @@ -5,14 +5,13 @@
"main": "index.js",
"scripts": {
"start": "next start",
"dev": "node server.js",
"dev": "next",
"build": "next build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.4",
"next": "latest",
"next-redux-wrapper": "^2.1.0",
"react": "^16.8.4",
Expand Down
28 changes: 7 additions & 21 deletions examples/form-handler/pages/_app.js
@@ -1,28 +1,14 @@
import App from 'next/app'
import React from 'react'
import { Provider } from 'react-redux'
import withRedux from 'next-redux-wrapper'
import { initStore } from '../store'

class MyApp extends App {
static async getInitialProps({ Component, router, ctx }) {
let pageProps = {}

if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}

return { pageProps }
}

render() {
const { Component, pageProps, store } = this.props
return (
<Provider store={store}>
<Component {...pageProps} />
</Provider>
)
}
const App = ({ Component, pageProps, store }) => {
return (
<Provider store={store}>
<Component {...pageProps} />
</Provider>
)
}

export default withRedux(initStore)(MyApp)
export default withRedux(initStore)(App)
36 changes: 32 additions & 4 deletions examples/form-handler/pages/index.js
@@ -1,13 +1,41 @@
import React, { Component } from 'react'
import Head from 'next/head'
import { Col, Row, Grid } from 'react-bootstrap'

import { connect } from 'react-redux'
import Header from '../components/Header'
import DisplayForm from '../components/DisplayForm'

import Main from '../components'
import UserForm from '../components/UserForm'
import Social from '../components/Social'

class Index extends Component {
render() {
return <Main />
return (
<div>
<Head>
<title>Form Handler</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"
/>
</Head>
<Grid>
<Header />
<DisplayForm />
<Row>
<Col lg={6}>
<UserForm />
</Col>
<Col lg={6}>
<Social />
</Col>
</Row>
</Grid>
</div>
)
}
}

export default connect()(Index)
export default Index
29 changes: 0 additions & 29 deletions examples/form-handler/server.js

This file was deleted.