Skip to content

Commit

Permalink
fix: conditional rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomura committed Nov 26, 2024
1 parent 165c70f commit b58e39a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
12 changes: 7 additions & 5 deletions packages/examples/vite/src/examples/page-wrap/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const styles = StyleSheet.create({
},
});

const PageWrap = () => (
const PageWrap = ({ value }) => (
<Document>
<Page style={styles.body}>
<Text style={styles.header} fixed>
Expand All @@ -73,10 +73,12 @@ const PageWrap = () => (
<Text style={styles.title}>Don Quijote de la Mancha</Text>
<Text style={styles.author}>Miguel de Cervantes</Text>
<Image style={styles.image} src={Quijote1} />
<Text style={styles.subtitle}>
Capítulo I: Que trata de la condición y ejercicio del famoso hidalgo D.
Quijote de la Mancha
</Text>
{value && (
<Text style={styles.subtitle}>
Capítulo I: Que trata de la condición y ejercicio del famoso hidalgo
D. Quijote de la Mancha
</Text>
)}
<Text style={styles.text}>
En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha
mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga
Expand Down
6 changes: 5 additions & 1 deletion packages/examples/vite/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PDFViewer } from '@react-pdf/renderer';
import EXAMPLES from './examples';

const ExamplesPage = () => {
const [bool, setBool] = useState(true);
const [hash, setHash] = useState(
window.location.hash.substring(1) || 'page-wrap',
);
Expand Down Expand Up @@ -42,8 +43,11 @@ const ExamplesPage = () => {
</nav>

<div key={hash} className="h-full flex-1">
<button type="button" onClick={() => setBool((prev) => !prev)}>
Toggle
</button>
<PDFViewer showToolbar={false} className="size-full">
<Document />
<Document value={bool} />
</PDFViewer>
</div>
</main>
Expand Down
2 changes: 1 addition & 1 deletion packages/reconciler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"ast-types": "^0.14.2",
"react-reconciler-26": "npm:react-reconciler@0.26.0",
"react-reconciler-23": "npm:react-reconciler@0.23.0",
"react-reconciler-31": "npm:[email protected]",
"recast": "^0.23.9"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/reconciler/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export default [
{
input: 'src/index.js',
output: { format: 'es', file: 'lib/index.js' },
external: ['./reconciler-26.js', './reconciler-31.js'],
external: ['./reconciler-23.js', './reconciler-31.js'],
},
{
input: 'src/reconciler-26.js',
output: { format: 'es', file: 'lib/reconciler-26.js' },
input: 'src/reconciler-23.js',
output: { format: 'es', file: 'lib/reconciler-23.js' },
plugins: [
resolve({ resolveOnly: ['react-reconciler-26'] }),
resolve({ resolveOnly: ['react-reconciler-23'] }),
commonjs({ esmExternals: (id) => id === 'scheduler' }),
trimReconciler(),
terser({ compress: { dead_code: true } }),
Expand Down
2 changes: 1 addition & 1 deletion packages/reconciler/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import React from 'react';
import createRendererForReact19 from './reconciler-31.js';
import createRendererForReact18AndLess from './reconciler-26.js';
import createRendererForReact18AndLess from './reconciler-23.js';

const isReact19 = React.version.startsWith('19');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/extensions */
/* eslint-disable import/no-extraneous-dependencies */
import Reconciler from 'react-reconciler-26/cjs/react-reconciler.production.min.js';
import Reconciler from 'react-reconciler-23/cjs/react-reconciler.production.min.js';

import propsEqual from './propsEqual';

Expand Down
21 changes: 15 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8734,14 +8734,15 @@ react-is@^18.0.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==

"react-reconciler-26@npm:react-reconciler@0.26.0":
version "0.26.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.26.0.tgz#053ae2fd1607e38a960e7a694ad694732e4989b6"
integrity sha512-n2FJE9vPSiZ0Dn/jaV/iOAO6rXepnk74QGRcgwPSgmN/2syUJnbfEz7Bw5yodBfJhjA3L7cu1YdImYISTj4KZQ==
"react-reconciler-23@npm:react-reconciler@0.23.0":
version "0.23.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.23.0.tgz#5f0bfc35dda030b0220c07de11f93131c5d6db63"
integrity sha512-vV0KlLimP9a/NuRcM6GRVakkmT6MKSzhfo8K72fjHMnlXMOhz9GlPe+/tCp5CWBkg+lsMUt/CR1nypJBTPfwuw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
scheduler "^0.20.0"
prop-types "^15.6.2"
scheduler "^0.17.0"

"react-reconciler-31@npm:[email protected]":
version "0.31.0-rc-603e6108-20241029"
Expand Down Expand Up @@ -9232,6 +9233,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.25.0-rc-66855b96-20241106.tgz#8bbb728eca4de5a5deca1f18370fbce41aee91d1"
integrity sha512-HQXp/Mnp/MMRSXMQF7urNFla+gmtXW/Gr1KliuR0iboTit4KvZRY8KYaq5ccCTAOJiUqQh2rE2F3wgUekmgdlA==

scheduler@^0.17.0:
version "0.17.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.17.0.tgz#7c9c673e4ec781fac853927916d1c426b6f3ddfe"
integrity sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"

scheduler@^0.19.1:
version "0.19.1"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
Expand All @@ -9240,7 +9249,7 @@ scheduler@^0.19.1:
loose-envify "^1.1.0"
object-assign "^4.1.1"

scheduler@^0.20.0, scheduler@^0.20.2:
scheduler@^0.20.2:
version "0.20.2"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91"
integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==
Expand Down

0 comments on commit b58e39a

Please sign in to comment.