react-multiple-page
It supports history block and prevent 'Back button'. It will be help when you build form tags in multiple page
Installation
npm i --save react-multiple-page
Usage
I recommend you to see /examples
src/App.js
about [BrowserRouter]
const customConfimation = {// ... refer to this Link https://gist.github.com/robertgonzales/e54699212da497740845712f3648d98c}const App =<Fragment><BrowserRouter getUserConfirmation=customConfimation><Switch>/* ... */<Route path="/form" component=FormPage /></Switch></BrowserRouter></Fragment>
src/components/pages/FormPage
about [using MultiplePageView]
const FormPage =<MultiplePageViewpages=Section1 Section2 Section3 // isRequiredmessage="메시지를 작성중입니다 정말 이 페이지를 떠나시겠습니까?" // isOptionable// when={false} // isOptionable...whatevers...props/>
src/components/pages/FormPage/Section1.js
const Section1 = {const pageController = props // from `react-multiple-page` property. that have a role control about this libreturn<div className="page"><div className="form-control"><h1> Hello I am Section1 </h1></div><div className="form-control"><button className="half-button" onClick=pageControllerprevPage>Prev</button><button className="half-button" onClick=pageControllernextPage>Next</button></div></div>}
Options
- when: ([ boolean | func ])
- message: ([ string | func ])
- pages: ([ Array: ...Components])
Section
Component
Transfer controller to Docs. Usage. 3 It will be help you.
- pageController: { nextPage, prevPage, goPage, when, message }
!! Caution !!
This source code using location.state
,
When you need to use location.state
for modal, popup and etc.., Please watch out drop away 'mp_page' in location.state
This source code use location.state. So, I recommand your source code change like this.
// (...)const location history = thisprops// history.replace(location.pathname, { ...location.state, mp_page })history// (...)
Specific Dependencies
- react-router v4
See examples directory.
It's in
- test code,
- lib/MultiplePageView.js that's core source.
- examples are here.
To do
https://github.com/gotsu/react-multiple-page/issues/2
License
Get more feedback
- If you got an error using my library, Please email me or leave an issue. I'll fix ya immediately.
- Any PR, Thanks.
Anyway, I'm happy to help you
References
- history block GIST robertgonzales/App.jsx
- history block on ReactTrainning/history