0.8.63 • Published 2 days ago

@stackend/react v0.8.63

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 days 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.63

2 days ago

0.8.62

7 months ago

0.8.61

7 months ago

0.8.60

7 months ago

0.8.58

9 months ago

0.8.57

9 months ago

0.8.59

7 months ago

0.8.56

11 months ago

0.8.55

1 year ago

0.8.52

1 year ago

0.8.51

1 year ago

0.8.54

1 year ago

0.8.53

1 year ago

0.8.50

1 year ago

0.8.49

1 year ago

0.8.48

1 year ago

0.8.45

1 year ago

0.8.44

1 year ago

0.8.47

1 year ago

0.8.46

1 year ago

0.8.43

2 years ago

0.8.13

2 years ago

0.8.9

2 years ago

0.8.8

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.7

2 years ago

0.8.6

2 years ago

0.8.1

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.8.12

2 years ago

0.8.11

2 years ago

0.8.10

2 years ago

0.8.0

2 years ago

0.7.55

2 years ago

0.7.54

2 years ago

0.7.57

2 years ago

0.7.56

2 years ago

0.7.53

2 years ago

0.7.52

2 years ago

0.7.58

2 years ago

0.7.51

2 years ago

0.7.50

2 years ago

0.7.44

2 years ago

0.7.43

2 years ago

0.7.46

2 years ago

0.7.45

2 years ago

0.7.42

2 years ago

0.7.41

2 years ago

0.7.48

2 years ago

0.7.47

2 years ago

0.7.49

2 years ago

0.7.33

2 years ago

0.7.32

2 years ago

0.7.34

2 years ago

0.7.31

2 years ago

0.7.30

2 years ago

0.7.37

2 years ago

0.7.36

2 years ago

0.7.39

2 years ago

0.7.38

2 years ago

0.7.22

2 years ago

0.7.21

2 years ago

0.7.24

2 years ago

0.7.23

2 years ago

0.7.20

2 years ago

0.7.29

2 years ago

0.7.25

2 years ago

0.7.28

2 years ago

0.7.27

2 years ago

0.7.40

2 years ago

0.7.19

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.11

2 years ago

0.7.10

2 years ago

0.7.9

2 years ago

0.7.13

2 years ago

0.7.12

2 years ago

0.7.6

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.7.18

2 years ago

0.7.15

2 years ago

0.7.14

2 years ago

0.7.17

2 years ago

0.7.16

2 years ago

0.7.0

2 years ago

0.6.3

3 years ago

0.6.4

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.3.33

3 years ago

0.3.32

3 years ago

0.3.31

3 years ago

0.3.30

3 years ago

0.3.29

3 years ago

0.3.28

3 years ago

0.3.27

3 years ago

0.3.26

3 years ago

0.3.25

3 years ago

0.3.24

3 years ago

0.3.23

3 years ago

0.3.22

3 years ago

0.3.20

3 years ago

0.3.21

3 years ago

0.3.19

3 years ago

0.3.18

3 years ago

0.3.17

3 years ago

0.3.16

3 years ago

0.3.15

3 years ago

0.3.14

3 years ago

0.3.13

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.9

3 years ago

0.3.10

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.4

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.3

3 years ago

0.2.4

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago