Using React in a multi-page app

后端 未结 6 875
滥情空心
滥情空心 2021-01-29 17:21

I have been playing around with React and so far I really like it. I am building an app with NodeJS and would like to use React for some of the interactive components across the

6条回答
  •  攒了一身酷
    2021-01-29 18:06

    Are you using a CMS? They tend to like changing urls which could break your application.

    Another way is using something like React Habitat.

    With it, you can register components and they automatically get exposed to the dom.

    Example

    Register component(s):

    container.register('AnimalBox', AnimalBox);
    container.register('AnimalSearchBox', AnimalSearchBox);
    

    Then they are availiable in your dom like this:

    The above will be automatically replaced with your react components.

    You can then automatically pass properties (or props) to your components too:

    This will expose size as a prop to your component. There are additional options for passing other types such as json, array's, ints, floats etc.

提交回复
热议问题