Skip to content

Commit

Permalink
fix: gatsby object object (#954)
Browse files Browse the repository at this point in the history
* init

* init

* remove log
  • Loading branch information
Aslemammad authored Feb 24, 2024
1 parent a00254b commit 5a7479f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/react-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
MillionProps,
Options,
} from '../types';
import { renderReactScope } from '../react/utils';
import { experimental_options } from '../experimental';

Check failure on line 28 in packages/react-server/index.ts

View workflow job for this annotation

GitHub Actions / build (19.x)

Identifier 'experimental_options' is not in camel case
import { useContainer, useNearestParent } from '../react/its-fine';
import { useSSRSafeId } from './utils';
Expand Down Expand Up @@ -179,8 +180,8 @@ export const importSource = (callback: () => void) => {

callback();
})
.catch(() => {
throw new Error('Failed to load Million.js');
.catch((e) => {
throw new Error('Failed to load Million.js: ' + e);
});
};

Expand Down Expand Up @@ -309,25 +310,25 @@ export function compiledBlock(
portals && portalCount > 0
? (props: MillionProps) => {
const [current] = useState<MillionPortal[]>(() => []);
// const [firstRender, setFirstRender] = useState(true)
const [firstRender, setFirstRender] = useState(true)

const derived = { ...props };

for (let i = 0; i < portalCount; i++) {
// const index = portals[i]!;
// derived[index] = renderReactScope(
// derived[index] as JSX.Element,
// false,
// current,
// i,
// );
const index = portals[i]!;
derived[index] = renderReactScope(
derived[index] as JSX.Element,
false,
current,
i,
);
}
const [targets] = useState<ReactPortal[]>([]);

// useEffect(() => {
// // showing targets for the first render causes hydration error!
// // setFirstRender(false)
// })
useEffect(() => {
// showing targets for the first render causes hydration error!
setFirstRender(false)
})
for (let i = 0, len = current.length; i < len; i++) {
targets[i] = current[i]!.portal;
}
Expand All @@ -337,7 +338,7 @@ export function compiledBlock(
{},
createElement(RenderBlock, derived),
// TODO: This should be uncommented, but doing that, value.reset would fail as it is undefined. This should be revisited
// !firstRender ? targets : undefined,
!firstRender ? targets : undefined,
);
}
: (props: MillionProps) => createElement(RenderBlock, props);
Expand Down
3 changes: 3 additions & 0 deletions website/pages/docs/install.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ export default {
};
```
</Tab>
<Callout type="warning">
The compiler will only try compiling `.jsx` or `.tsx` files and will not try doing any transformation to any other file. You either convert your file formats to those formats or use the [Manual Mode](/docs/manual-mode/manual-mode).
</Callout>

</Tabs>

Expand Down

0 comments on commit 5a7479f

Please sign in to comment.