-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
packages/component-component/__tests__/__snapshots__/component-component.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Component /> didMount is not required 1`] = ` | ||
<h1> | ||
No need for didMount prop for rendering! | ||
</h1> | ||
`; | ||
|
||
exports[`<Component /> didUpdate is not required 1`] = ` | ||
<h1> | ||
Can render without didUpdate prop! | ||
</h1> | ||
`; | ||
|
||
exports[`<Component /> getSnapshotBeforeUpdate is not required 1`] = ` | ||
<h1> | ||
getSnapshotBeforeUpdate prop is not necessary for render! | ||
</h1> | ||
`; | ||
|
||
exports[`<Component /> prefers \`render\` over \`children\` 1`] = ` | ||
<div> | ||
<h1> | ||
Render with an actual "render" prop | ||
</h1> | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> renders with children render prop 1`] = ` | ||
<div> | ||
<h1> | ||
Using children prop as render prop! | ||
</h1> | ||
<p> | ||
This is a pretty neat pattern. I'm really glad someone thought of it. | ||
</p> | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> renders with normal children 1`] = ` | ||
<div> | ||
<h1> | ||
Some regular children! | ||
</h1> | ||
<p> | ||
This is another child in the regular children group. | ||
</p> | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> renders without children 1`] = `null`; | ||
|
||
exports[`<Component /> renders without figuritively exploding 1`] = ` | ||
<div> | ||
Heyyyooooo | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> shouldUpdate is not required 1`] = ` | ||
<h1> | ||
Can render without shouldUpdate prop. | ||
</h1> | ||
`; | ||
|
||
exports[`<Component /> state calls getInitialState 1`] = ` | ||
<div> | ||
<h1> | ||
Jane Fonda | ||
</h1> | ||
<h2> | ||
Favorites | ||
</h2> | ||
<ol> | ||
<li> | ||
Color: | ||
green | ||
</li> | ||
<li> | ||
Food: | ||
calzones | ||
</li> | ||
</ol> | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> state receives initialState 1`] = ` | ||
<div> | ||
<h1> | ||
Henry Winkler | ||
</h1> | ||
<h2> | ||
Favorites | ||
</h2> | ||
<ol> | ||
<li> | ||
Color: | ||
purple | ||
</li> | ||
<li> | ||
Food: | ||
cheeseburgers | ||
</li> | ||
</ol> | ||
</div> | ||
`; | ||
|
||
exports[`<Component /> willUnmount is not required 1`] = ` | ||
<h1> | ||
Don't need willUnmount prop in order to render! | ||
</h1> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
declare const __DEV__: boolean; | ||
|
||
declare module "@reach/component-component" { | ||
import React from "react"; | ||
interface ComponentProps< | ||
State extends object = {}, | ||
Refs extends object = {} | ||
> { | ||
[key: string]: any; | ||
initialState?: State; | ||
getInitialState?: (props: ComponentProps<State>) => State; | ||
refs?: Refs; | ||
getRefs?: (...args: any[]) => Refs; | ||
didMount?: (...args: any[]) => void; | ||
didUpdate?: (...args: any[]) => void; | ||
willUnmount?: (...args: any[]) => void; | ||
getSnapshotBeforeUpdate?: (...args: any[]) => any; | ||
shouldUpdate?: (args: { | ||
props: ComponentProps<State>; | ||
state: State; | ||
nextProps: ComponentProps<State>; | ||
nextState: State; | ||
}) => boolean; | ||
render?: (...args: any[]) => React.ReactElement | null; | ||
children?: | ||
| ((...args: any[]) => React.ReactElement | null) | ||
| React.ReactNode | ||
| React.ReactElement | ||
| Element | ||
| null; | ||
} | ||
class Component< | ||
State extends object = {}, | ||
Refs extends object = {} | ||
> extends React.Component<ComponentProps<State, Refs>, State> {} | ||
export default Component; | ||
} |