stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.04k stars 391 forks source link

React snap worked with only main page. #431

Closed mahabbatmh closed 4 years ago

mahabbatmh commented 4 years ago

I have issue with react-snap configuration. my index.js: `import React from 'react'; import './index.css'; import App from './App'; import { AComponent, BComponent } from "./App"; import { BrowserRouter, Route ,Switch } from 'react-router-dom'; import { hydrate, render } from "react-dom"; const Routing = () => (

);

const rootElement = document.getElementById("root"); if (rootElement.hasChildNodes()) { hydrate(, rootElement); } else { render(, rootElement); } `

App.js

`import React from 'react'; import logo from './logo.svg'; import './App.css'; import { Link } from "react-router-dom";

export function AComponent(){ return (

Home B component

) }

export function BComponent(){ return (

Home A component

) }

function App() { return (

logo

Edit src/App.js and save to reload.

A component B component

); }`

export default App;

package.json:

{ "name": "prerender", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-router-dom": "^5.1.2", "react-scripts": "3.3.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "postbuild": "react-snap" }, "eslintConfig": { "extends": "react-app" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "react-snap": "^1.23.0" } }

When I reloaded/a path, I get HTML of main page.

bruno-silva5 commented 1 year ago

@mahabbatmh I'm having the same issue. Were you able to solve the problem?