Skip to content

Commit

Permalink
docs: remove defaultProps from components
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed May 14, 2024
1 parent bf1f9bb commit a66d51e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 45 deletions.
4 changes: 3 additions & 1 deletion docs/core/api/useQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import VoteDemo from '../shared/\_VoteDemo.mdx';

Query the store.

Renders any [Queryable Schema](/rest/api/schema#queryable) from the store.
Renders any [Queryable Schema](/rest/api/schema#queryable) like [Entity](/rest/api/Entity), [All](/rest/api/All), [Collection](/rest/api/Collection), [Query](/rest/api/Query),
and [Union](/rest/api/Union) from the store.

[Queries](/rest/api/Query) are a great companion to efficiently render aggregate computations like those that use [groupBy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy#browser_compatibility),
[map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map), [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce), and [filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).

Expand Down
15 changes: 5 additions & 10 deletions website/src/components/HooksPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ const HooksPlayground = ({
children,
groupId,
hidden = false,
defaultOpen,
defaultOpen = 'n',
row = false,
fixtures,
fixtures = [],
defaultTab,
getInitialInterceptorData,
getInitialInterceptorData = () => ({}),
}: PlaygroundProps) => (
<Playground
noInline
Expand All @@ -34,21 +34,16 @@ const HooksPlayground = ({
: children.props.children}
</Playground>
);
HooksPlayground.defaultProps = {
defaultOpen: 'n' as const,
fixtures: [] as Fixture[],
getInitialInterceptorData: () => ({}),
};
export default memo(HooksPlayground);

//child.props.children.props.title

interface PlaygroundProps<T = any> {
groupId: string;
defaultOpen: 'y' | 'n';
defaultOpen?: 'y' | 'n';
row: boolean;
hidden: boolean;
fixtures: (Fixture | Interceptor<T>)[];
fixtures?: (Fixture | Interceptor<T>)[];
getInitialInterceptorData?: () => T;
children: React.ReactNode;
reverse?: boolean;
Expand Down
5 changes: 1 addition & 4 deletions website/src/components/Playground/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Header({
children,
className,
onClick,
small,
small = false,
}: {
children: React.ReactNode;
className?: string;
Expand All @@ -33,6 +33,3 @@ export default function Header({
</div>
);
}
Header.defaultProps = {
small: false,
};
18 changes: 6 additions & 12 deletions website/src/components/Playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type LiveProviderProps = {
noInline?: boolean;
scope?: Record<string, unknown>;
theme?: PrismTheme;
hidden?: boolean;
transformCode?(code: string): void;
};

Expand All @@ -31,16 +32,16 @@ export default function Playground<T>({
transformCode,
groupId,
defaultOpen,
row,
hidden,
row = false,
hidden = false,
fixtures,
getInitialInterceptorData,
defaultTab,
...props
}: Omit<LiveProviderProps, 'ref'> & {
groupId: string;
defaultOpen: 'y' | 'n';
row: boolean;
row?: boolean;
children: string | any[];
fixtures: (Fixture | Interceptor<T>)[];
getInitialInterceptorData?: () => T;
Expand Down Expand Up @@ -77,10 +78,6 @@ export default function Playground<T>({
</>
);
}
Playground.defaultProps = {
row: false,
hidden: false,
};

function PlaygroundContent<T>({
reverse,
Expand Down Expand Up @@ -155,10 +152,10 @@ const PreviewWithScopeLazy = lazy(() =>

function Reversible({
children,
reverse,
reverse = false,
}: {
children: React.ReactNode[];
reverse: boolean;
reverse?: boolean;
}): React.ReactElement {
const newchild = [...children];
newchild.reverse();
Expand All @@ -167,6 +164,3 @@ function Reversible({
}
return children as any;
}
Reversible.defaultProps = {
reverse: false,
};
26 changes: 8 additions & 18 deletions website/src/components/StackBlitz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { useHasIntersected } from './useHasIntersected';

export default function StackBlitz({
app,
width,
height,
hidedevtools,
view,
terminalHeight,
hideNavigation,
width = '100%',
height = '500',
hidedevtools = '1',
view = 'both',
terminalHeight = '0',
hideNavigation = '1',
file,
ctl,
initialpath,
ctl = '0',
initialpath = '',
}) {
const embed = '1';
const params = new URLSearchParams({
Expand Down Expand Up @@ -74,13 +74,3 @@ export default function StackBlitz({
</>
);
}
StackBlitz.defaultProps = {
width: '100%',
height: '500',
hidedevtools: '1',
view: 'both',
terminalHeight: '0',
hideNavigation: '1',
ctl: '0',
initialpath: '',
};

0 comments on commit a66d51e

Please sign in to comment.