Skip to content

Commit cb82a0d

Browse files
committed
chore: fix demo
1 parent e2e2a9c commit cb82a0d

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

docs/examples/simple.tsx

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint no-console:0 */
22

3-
import Trigger, { ActionType } from '@rc-component/trigger';
3+
import Trigger, { type ActionType } from '@rc-component/trigger';
44
import React from 'react';
55
import '../../assets/index.less';
66

@@ -43,29 +43,26 @@ function getPopupContainer(trigger) {
4343
return trigger.parentNode;
4444
}
4545

46-
const InnerTarget = (props) => (
47-
<div
48-
style={{
49-
margin: 20,
50-
display: 'inline-block',
51-
background: 'rgba(255, 0, 0, 0.05)',
52-
}}
53-
tabIndex={0}
54-
role="button"
55-
{...props}
56-
>
57-
<p>This is a example of trigger usage.</p>
58-
<p>You can adjust the value above</p>
59-
<p>which will also change the behaviour of popup.</p>
60-
</div>
46+
const InnerTarget = React.forwardRef(
47+
(props: any, ref: React.Ref<HTMLElement>) => (
48+
<div
49+
style={{
50+
margin: 20,
51+
display: 'inline-block',
52+
background: 'rgba(255, 0, 0, 0.05)',
53+
}}
54+
tabIndex={0}
55+
role="button"
56+
{...props}
57+
ref={ref}
58+
>
59+
<p>This is a example of trigger usage.</p>
60+
<p>You can adjust the value above</p>
61+
<p>which will also change the behavior of popup.</p>
62+
</div>
63+
),
6164
);
6265

63-
const RefTarget = React.forwardRef((props, ref) => {
64-
React.useImperativeHandle(ref, () => ({}));
65-
66-
return <InnerTarget {...props} />;
67-
});
68-
6966
interface TestState {
7067
mask: boolean;
7168
maskClosable: boolean;
@@ -88,7 +85,7 @@ interface TestState {
8885

8986
class Test extends React.Component<any, TestState> {
9087
state: TestState = {
91-
mask: true,
88+
mask: false,
9289
maskClosable: true,
9390
placement: 'bottom',
9491
trigger: {
@@ -377,7 +374,7 @@ class Test extends React.Component<any, TestState> {
377374
motionName: state.transitionName,
378375
}}
379376
>
380-
<RefTarget />
377+
<InnerTarget />
381378
</Trigger>
382379
</div>
383380
</div>

0 commit comments

Comments
 (0)