Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react): building app for production now works correctly with vite #24515

Merged
merged 3 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-virtual": "^2.0.3",
"@stencil/angular-output-target": "^0.4.0",
"@stencil/react-output-target": "^0.2.0",
"@stencil/react-output-target": "^0.2.1",
"@stencil/sass": "1.3.2",
"@stencil/vue-output-target": "^0.6.0",
"@types/jest": "^26.0.20",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OverlayEventDetail } from '@ionic/core/components'
import React from 'react';
import React, { createElement } from 'react';

import {
attachProps,
Expand Down Expand Up @@ -119,8 +119,8 @@ export const createInlineOverlayComponent = <PropType, ElementType>(
* so conditionally render the component
* based on the isOpen state.
*/
return React.createElement(tagName, newProps, (this.state.isOpen) ?
React.createElement('div', {
return createElement(tagName, newProps, (this.state.isOpen) ?
createElement('div', {
id: 'ion-react-wrapper',
ref: this.wrapperRef,
style: { height: '100%' }
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/createRoutingComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnimationBuilder } from '@ionic/core/components';
import React from 'react';
import React, { createElement } from 'react';

import { NavContext } from '../contexts/NavContext';
import { RouterOptions } from '../models';
Expand Down Expand Up @@ -104,7 +104,7 @@ export const createRoutingComponent = <PropType, ElementType>(
newProps.onClick = this.handleClick;
}

return React.createElement(tagName, newProps, children);
return createElement(tagName, newProps, children);
}

static get displayName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { createElement } from 'react';

import {
attachProps,
Expand Down Expand Up @@ -80,7 +80,14 @@ export const createReactComponent = <
style,
};

return React.createElement(tagName, newProps, children);
/**
* We use createElement here instead of
* React.createElement to work around a
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
* React.createElement causes all elements to be rendered
* as <tagname> instead of the actual Web Component.
*/
return createElement(tagName, newProps, children);
}

static get displayName() {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useOverlay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OverlayEventDetail } from '@ionic/core/components';
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import React, { createElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';

import { attachProps } from '../components/react-component-lib/utils';
import { IonContext } from '../contexts/IonContext';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function useOverlay<OptionsType, OverlayType extends OverlayBase>(
if (React.isValidElement(component)) {
ionContext.addOverlay(overlayId, component, containerElRef.current!);
} else {
const element = React.createElement(component as React.ComponentClass, componentProps);
const element = createElement(component as React.ComponentClass, componentProps);
ionContext.addOverlay(overlayId, element, containerElRef.current!);
}
}
Expand Down