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

Adds onMouseEnter/onMouseLeave example to View page #212

Merged
merged 2 commits into from
May 17, 2022
Merged
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
28 changes: 27 additions & 1 deletion src/examples/ViewExamplePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
import {View} from 'react-native';
import React from 'react';
import React, {useState} from 'react';
import {Example} from '../components/Example';
import {Page} from '../components/Page';
import {useTheme} from '@react-navigation/native';
Expand Down Expand Up @@ -123,6 +123,19 @@ style={{
}}
/>`;

const example9jsx = `const [onHover, setOnHover] = useState(false);
<View
onMouseEnter={() => setOnHover(true)}
onMouseLeave={() => setOnHover(false)}
style={{
height: 50,
width: 100,
backgroundColor: onHover? colors.notification: colors.primary,
}}
/>`;

const [onHover, setOnHover] = useState(false);

return (
<Page
title="View"
Expand Down Expand Up @@ -292,6 +305,19 @@ style={{
}}
/>
</Example>
<Example
title="A View with onMouseEnter/onMouseLeave."
code={example9jsx}>
<View
onMouseEnter={() => setOnHover(true)}
onMouseLeave={() => setOnHover(false)}
style={{
height: 50,
width: 100,
backgroundColor: onHover ? colors.notification : colors.primary,
}}
/>
</Example>
</Page>
);
};