0.8.91 • Published 8 months ago

@stackend/react v0.8.91

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
8 months ago

About Stackend

Stackend.com is backend, frontend & hosting in a single line of code, or if you prefer - a downloadable NPM package. It contains of hosted, pre-made modules with focus on community driven features that you can add to your new or existing project. To use Stackend you need to create a Stackend account, and a Stack (your cloud based backend, frontend and admin).

Stackend React

This library contains React components for Stackend modules.

NOTE: Right now this library is under development and not ready for general use. The API may change at any time. Use on your own risk.

Installation

npm install --save @stackend/api @stackend/react

Noteworthy Dependencies

Setup

You will need to set up a Redux store and initialize the API with the community you will use:

import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { STANDARD_REDUCERS } from '@stackend/api/api/reducers';
import { REDUCERS } from '@stackend/react/reducers';
import { initialize } from '@stackend/api/api/actions';
import { getCurrentCommunity } from '@stackend/api';

// Possibly add your own reducers and middleware here
const reducers = {
  ...STANDARD_REDUCERS,
  ...REDUCERS
};

const store = createStore(combineReducers(reducers), {}, compose(applyMiddleware(thunk)));

await store.dispatch(
  initialize({
    permalink: 'stackend-com' /* Replace with your community permalink */
  })
);

Then you can write your own application using Stackend components: Add LoadingThrobber and ModalThrobber to get feedback when backend requests are made.

import LoadingThrobber from '@stackend/react/throbber/LoadingThrobber';
import ModalThrobber from '@stackend/react/throbber/ModalThrobber';
import Content from '@stackend/react/cms/Content';
import { Content as CmsContent } from '@stackend/api/cms';
import { CmsState } from '@stackend/api/cms/cmsReducer';
import { fetchContent } from '@stackend/api/cms/cmsActions';
import { connect } from 'react-redux';

const MY_CMS_ID = 123;

type Props = {
  content: CmsContent;
};

const mapDispatchToProps = {
  fetchContent
};

function mapStateToProps(state: any) {
  const cms: CmsState = state.cmsContent;
  return {
    content: cms[MY_CMS_ID]
  };
}

class MyApp extends Component<Props> {
  componentDidMount() {
    this.props.fetchContent({ id: MY_CMS_ID });
  }

  render() {
    const { content } = this.props;
    return (
      <div>
        {/* Stackend throbbers used to indicate when the app is loading / saving */}
        <LoadingThrobber />
        <ModalThrobber />

        {/* A stackend component displaying some cms content */}
        <Content content={content} />
      </div>
    );
  }
}

export default connect(mapStateToProps, mapDispatchToProps)(MyApp);
0.8.89

1 year ago

0.8.88

1 year ago

0.8.85

1 year ago

0.8.84

1 year ago

0.8.87

1 year ago

0.8.86

1 year ago

0.8.83

1 year ago

0.8.82

1 year ago

0.8.91

8 months ago

0.8.90

1 year ago

0.8.81

1 year ago

0.8.80

1 year ago

0.8.79

1 year ago

0.8.78

1 year ago

0.8.77

1 year ago

0.8.74

1 year ago

0.8.73

1 year ago

0.8.76

1 year ago

0.8.75

1 year ago

0.8.70

1 year ago

0.8.72

1 year ago

0.8.71

1 year ago

0.8.67

1 year ago

0.8.66

1 year ago

0.8.69

1 year ago

0.8.68

1 year ago

0.8.65

2 years ago

0.8.64

2 years ago

0.8.63

2 years ago

0.8.62

2 years ago

0.8.61

2 years ago

0.8.60

2 years ago

0.8.58

2 years ago

0.8.57

2 years ago

0.8.59

2 years ago

0.8.56

3 years ago

0.8.55

3 years ago

0.8.52

3 years ago

0.8.51

3 years ago

0.8.54

3 years ago

0.8.53

3 years ago

0.8.50

3 years ago

0.8.49

3 years ago

0.8.48

3 years ago

0.8.45

3 years ago

0.8.44

3 years ago

0.8.47

3 years ago

0.8.46

3 years ago

0.8.43

3 years ago

0.8.13

4 years ago

0.8.9

4 years ago

0.8.8

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.1

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.12

4 years ago

0.8.11

4 years ago

0.8.10

4 years ago

0.8.0

4 years ago

0.7.55

4 years ago

0.7.54

4 years ago

0.7.57

4 years ago

0.7.56

4 years ago

0.7.53

4 years ago

0.7.52

4 years ago

0.7.58

4 years ago

0.7.51

4 years ago

0.7.50

4 years ago

0.7.44

4 years ago

0.7.43

4 years ago

0.7.46

4 years ago

0.7.45

4 years ago

0.7.42

4 years ago

0.7.41

4 years ago

0.7.48

4 years ago

0.7.47

4 years ago

0.7.49

4 years ago

0.7.33

4 years ago

0.7.32

4 years ago

0.7.34

4 years ago

0.7.31

4 years ago

0.7.30

4 years ago

0.7.37

4 years ago

0.7.36

4 years ago

0.7.39

4 years ago

0.7.38

4 years ago

0.7.22

4 years ago

0.7.21

4 years ago

0.7.24

4 years ago

0.7.23

4 years ago

0.7.20

4 years ago

0.7.29

4 years ago

0.7.25

4 years ago

0.7.28

4 years ago

0.7.27

4 years ago

0.7.40

4 years ago

0.7.19

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.11

4 years ago

0.7.10

4 years ago

0.7.9

4 years ago

0.7.13

4 years ago

0.7.12

4 years ago

0.7.6

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.18

4 years ago

0.7.15

4 years ago

0.7.14

4 years ago

0.7.17

4 years ago

0.7.16

4 years ago

0.7.0

4 years ago

0.6.3

4 years ago

0.6.4

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.0

5 years ago

0.5.1

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.3.33

5 years ago

0.3.32

5 years ago

0.3.31

5 years ago

0.3.30

5 years ago

0.3.29

5 years ago

0.3.28

5 years ago

0.3.27

5 years ago

0.3.26

5 years ago

0.3.25

5 years ago

0.3.24

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.20

5 years ago

0.3.21

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.13

5 years ago

0.3.12

5 years ago

0.3.11

5 years ago

0.3.9

5 years ago

0.3.10

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.4

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.3

5 years ago

0.2.4

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago