简体   繁体   中英

How to connect two (or more) separate react applications into one?

I believe it is an easy fix, but I'm unsure of how to do it.

I have two separate react applications all meant to be connected. One of them is a sign-up section which is connecting to the server and passing on information, the second is currently the profile page. Once a user signs up, they're redirected to the profile with all of the information they have just entered.

I would like to connect the profile react-app to the sign-up one. I know they can be treated as components and exported as such, but I don't know how to approach it.

EDIT:

I ended up putting all of the applications under one big react project and connecting them as you would any other regular page. They all have separate servers that can be initiated by the commands I've given them in package.json & webpack config file.

I also created one command to run all of the servers at once to test all locally.

And I've created another command to run the build command which, in the end, has everything running by inputting the python run script.

React router will help you navigate through your components (Redirect, Link, etc...).

Philosophy and tutorial :

https://reacttraining.com/react-router/web/guides/philosophy

GitHub:

https://github.com/ReactTraining/react-router

You should use react-router https://github.com/ReactTraining/react-router react-router has a prop that is history when your form send request to server and server response is success you can do this with history:

this.props.history.push(/profile-page)

and set the results to redux and use then in your profile component

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM