I am a noob using create-react-app
to create a App, yarn start
start the server at http://localhost:3000/
, I can't visit this url on my mobile.
How can I make some configs to preview the app on my mobile?
相关问题
- How to toggle on Order in ReactJS
- Refreshing page gives Cannot GET /page_url in reac
- Adding a timeout to a render function in ReactJS
- React Native Inline style for multiple Text in sin
- Issue with React.PropTypes.func.isRequired
相关文章
- Why would we use useEffect without a dependency ar
- Is it possible to get ref of props.children?
- Stateless function components cannot be given refs
- React testing library: Test attribute / prop
- React/JestJS/Enzyme: How to test for ref function?
- RMI Threads prevent JVM from exiting after main()
- Material-UI [v0.x] RaisedButton on hover styles
- Remove expo from react native
If you want to test it on an actual device (That is what is recommended) you should ensure that you mobile phone is connected to the same network as you computer is and then when you run
You should see something like this:
Just put that IP address in your mobile browser and test your web application
Add a hostname to your
hosts
file that points to localhost. On Windows its usually located atC:\Windows\System32\drivers\etc
, on Linux it lives at/etc/hosts
, e.g.:127.0.0.1 my-app.dev
Then setup a proxy server on your machine and configure your phone to use that as its proxy.
You should then be able to access your app via your phone's browser using the hostname specified above as URL.
First, remember you can open a mobile view in a desktop browser (at least in Chrome and Firefox). See the article for more. It isn't a substitute of testing on a real mobile device but can help you identify more obvious issues.
Second, you need to use the IP address of your computer in your local network (assuming your mobile device is on the same network as your desktop). On Linux and Mac you can check your IP with
ipconfig
.localhost
always refers to the current machine, i.e.localhost
on your desktop points to your desktop and on your mobile device it points to your mobile device. That's why you can't access it - the app runs on your desktop not mobile.Once you know the IP address of your computer you need to replace
localhost
with it. In my case the IP is 192.168.1.10 so I use the following address to access my app:For windows:
http://your_ip:3000
to preview your react app.