https://github.com/mrblueblue/react-submit-button
Submit button React Component that renders according to your submission state
https://github.com/mrblueblue/react-submit-button
Last synced: 2 months ago
JSON representation
Submit button React Component that renders according to your submission state
- Host: GitHub
- URL: https://github.com/mrblueblue/react-submit-button
- Owner: mrblueblue
- Created: 2015-11-07T05:35:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-07T06:17:26.000Z (over 9 years ago)
- Last Synced: 2025-02-06T01:44:32.856Z (4 months ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-submit-button
A Stateless Function Component for your submit button needs.
``` javascript
import React from 'react';
import SubmitButton from 'react-submit-button';const SubmitButtonContainer = ({status, asyncAction}) => (
)```
`status` is basically state that is passed down as a prop. It should conform to either `loading`, `success`, `error`. Its default or ready state can be any string.
`asyncAction` is an asynchronous action (most likely a promise chain) that updates the `status` state depending on the async action's ongoingness, success, or failure. For instance, in the parent Component of ``, one might find a promise chain like this:
```javascript
this.setState({status: 'loading'});
fetch(my.api.endpoit)
.then((data) => {
doSomething(data);
this.setState({status: 'success'});
})
.catch((error) => {
doSomethingElse(error);
this.setState({status: 'error'})
});```