Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function applyImageProps(

// Component-specific props

// RN Image fades in over 300ms on Android by default. That is not a web
// behavior, so disable it. CSS transitions can still animate opacity.
nativeProps.fadeDuration = 0;

nativeProps.ref = elementRef;
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-strict-dom/src/types/renderer.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type ReactNativeProps = {
disabled?: ?boolean,
editable?: TextInputProps['editable'],
enterKeyHint?: TextInputProps['enterKeyHint'],
fadeDuration?: ImageProps['fadeDuration'],
focusable?: ?boolean,
height?: ImageProps['height'],
importantForAccessibility?: 'no-hide-descendants',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`<compat.native> "as" equals "div": as=div 1`] = `
exports[`<compat.native> "as" equals "img": as=img 1`] = `
<Image
accessibilityLabel="label"
fadeDuration={0}
ref={[Function]}
srcSet="1x.img, 2x.img 2x"
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3057,6 +3057,7 @@ exports[`<html.*> "i" supports inline event handlers 1`] = `

exports[`<html.*> "img" default rendering 1`] = `
<Image
fadeDuration={0}
ref={[Function]}
style={
{
Expand All @@ -3070,6 +3071,7 @@ exports[`<html.*> "img" default rendering 1`] = `

exports[`<html.*> "img" ignores and warns about unsupported attributes 1`] = `
<Image
fadeDuration={0}
ref={[Function]}
style={
{
Expand All @@ -3085,6 +3087,7 @@ exports[`<html.*> "img" supports additional image attributes 1`] = `
<Image
alt="Alt text"
crossOrigin="anonymous"
fadeDuration={0}
height={100}
onError={[Function]}
onLoad={[Function]}
Expand Down Expand Up @@ -3136,6 +3139,7 @@ exports[`<html.*> "img" supports global attributes 1`] = `
}
}
accessibilityViewIsModal={true}
fadeDuration={0}
focusable={true}
importantForAccessibility="no-hide-descendants"
nativeID="some-id"
Expand All @@ -3159,6 +3163,7 @@ exports[`<html.*> "img" supports global attributes 1`] = `

exports[`<html.*> "img" supports inline event handlers 1`] = `
<Image
fadeDuration={0}
onBlur={[Function]}
onFocus={[Function]}
onGotPointerCapture={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ exports[`<html.*> (native polyfills) polyfills: layout default flex layout: flex
exports[`<html.*> (native polyfills) polyfills: props <img> "src" prop with loading props 1`] = `
<Image
crossOrigin="use-credentials"
fadeDuration={0}
ref={[Function]}
referrerPolicy="no-referrer"
src="https://src.jpg"
Expand All @@ -235,6 +236,7 @@ exports[`<html.*> (native polyfills) polyfills: props <img> "src" prop with load
exports[`<html.*> (native polyfills) polyfills: props <img> "srcSet" prop with loading props 1`] = `
<Image
crossOrigin="use-credentials"
fadeDuration={0}
ref={[Function]}
referrerPolicy="no-referrer"
srcSet="https://src.jpg 1x, https://srcx2.jpg 2x"
Expand Down
8 changes: 8 additions & 0 deletions packages/react-strict-dom/tests/html/html-test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ describe('<html.*> (native polyfills)', () => {
expect(root.toJSON()).toMatchSnapshot();
});

test('disables Android fadeDuration default', () => {
let root;
act(() => {
root = create(<html.img src="https://src.jpg" />);
});
expect(root.toJSON().props.fadeDuration).toBe(0);
});

test('"onError" and "onLoad" prop', () => {
const onError = jest.fn();
const onLoad = jest.fn();
Expand Down