Comments (2)
Thanks for your response and help!
Looks like the culprit was actually just the wordpress site not being live. So when I refreshed on
example.com/~wpuser/examplepage. It would break just due to the url not matching, because my react router replacement was assuming that there would be no /~wpuser in the url. Once live without the ~wpuser it works fine when refreshing on /example page.
Thank you!
from create-react-wptheme.
Hi Stephen,
TL;DR: there was a bug in the "npm run build" command a couple of weeks ago. Check out the Updating instructions in the README and do that first. Then try modifying the user.prod.json file per the Build Configuration instructions. Hopefully npm run build
will just work correctly for you then.
Here was the issue ticket for that bug, if you're interested: user.prod.json homepage property not used on wpbuild
If that doesn't just work for you, then you're going to have to read The Long Answer ;)
First off, there is no "wp-dev server" serving your pages. That's the whole point of this project, it is your WordPress server serving your theme. There is a little web-socket server running, but all it does it tell your browser that you made changes and then your browser refreshes when that happens.
So the fact that it works in your dev environment leads me to hope that you're just using the old version with the build bug. Sorry about that!
If updating and double-checking your user.prod.json
file doesn't work, then I'm going to be a little stuck trying to help... I'm not much of a React-Router expert. But you might look at this tutorial, the author does use React Router in his theme: How To Build A Skin For Your Web App With React And WordPress
Finally, there might be some kind of hack you can come up with using either Webpack's "%PUBLIC_URL%" feature (see references to that in the index.php file in your public folder) or getting your theme's URL using PHP, like I do here in this file: post_installer.php. I do think that using either method is indeed a hack, so be careful.
Let me know how it goes!
Thanks,
-joe
from create-react-wptheme.
Related Issues (20)
- Support for other template files HOT 3
- How do I get the post data?
- You haven't yet completed the PHP portion of your new theme's setup. Bugg ??
- static/js directory not updating
- Edit the new theme from wp editor
- Browser Refresh not working in warning state HOT 2
- Bad precaching response HOT 1
- dev server error Upgrade Required HOT 1
- Is it possible to use custom fields? Just like the ACF plugin? HOT 1
- Environment variable HOT 1
- Watch Ignore and navigation url
- prototype pollution and remote code execution HOT 1
- Update to Latest Create-React-App Version
- Router Not Working HOT 2
- Project Depreciated?
- How to do SSR with create-react-wptheme. HOT 1
- Update Webpack to use more secure hashing routines
- Featured Image HOT 2
- yarn start Fails with Open SSL message HOT 2
- Compatibility with Node 20 LTS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-react-wptheme.