apply suggestions
continuous-integration/drone/push Build is passing Details

pull/3/head
maxime.batista 1 year ago
parent e7f5cc72c5
commit 7df33f32b5

@ -144,7 +144,7 @@ function _asset(string $assetURI): string {
Conventions regarding our react views __must be respected in order to be renderable__. Conventions regarding our react views __must be respected in order to be renderable__.
### The `render(any)` function ### The `render(any)` function
__any react view file__ should __export__ a function with signature `render(arguments: any)`, which responsibility is to render the view. Any React view component needs to be default exported in order to be imported and used from PHP. Those components will receive as props the arguments that the PHP server has transmitted.
The `arguments` parameter is used to pass data to the react component. The `arguments` parameter is used to pass data to the react component.
If you take a look at the `front/views/SampleForm.tsx` view, here's the definition of its render function : If you take a look at the `front/views/SampleForm.tsx` view, here's the definition of its render function :

@ -4,7 +4,6 @@
"App\\": "src/" "App\\": "src/"
} }
}, },
"include-path": ["src"],
"require": { "require": {
"altorouter/altorouter": "1.2.0", "altorouter/altorouter": "1.2.0",
"ext-json": "*" "ext-json": "*"

@ -12,7 +12,7 @@
"@types/react-dom": "^18.2.14", "@types/react-dom": "^18.2.14",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"typescript": "^4.9.5", "typescript": "^5.2.2",
"vite": "^4.5.0", "vite": "^4.5.0",
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"
}, },
@ -27,18 +27,6 @@
"react-app/jest" "react-app/jest"
] ]
}, },
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": { "devDependencies": {
"@vitejs/plugin-react": "^4.1.0" "@vitejs/plugin-react": "^4.1.0"
} }

@ -34,8 +34,8 @@ $match = $router->match();
if ($match == null) { if ($match == null) {
// TODO redirect to a 404 not found page instead (issue #1) // TODO redirect to a 404 not found page instead (issue #1)
echo "page non trouvée"; http_response_code(404);
header('HTTP/1.1 404 Not Found'); echo "Page non trouvée";
exit(1); exit(1);
} }

@ -2,7 +2,7 @@
namespace App\Controller; namespace App\Controller;
require_once "react-display.php"; require_once __DIR__ . "/../react-display.php";
class SampleFormController { class SampleFormController {
public function displayForm() { public function displayForm() {

@ -10,11 +10,11 @@
RefreshRuntime.injectIntoGlobalHook(window) RefreshRuntime.injectIntoGlobalHook(window)
window.\$RefreshReg$ = () => {} window.\$RefreshReg$ = () => {}
window.\$RefreshSig$ = () => (type) => type window.\$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
"; ";
} }
?> ?>
window.__vite_plugin_react_preamble_installed__ = true
</script> </script>
<link rel="icon" href="<?= asset("assets/favicon.ico") ?>"> <link rel="icon" href="<?= asset("assets/favicon.ico") ?>">
@ -24,7 +24,9 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title> <title>Document</title>
</head> </head>
<body id="root"> <body>
<div id="root"></div>
<!-- <!--
here's the magic. here's the magic.

Loading…
Cancel
Save