forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flight] Expand the fixture to use require.extensions (facebook#20209)
* Expand fixture Use .server convention. /server/index.js should really change too so it can be compiled but for now we treat it as bootstrapping code outside the compiled code. Move App.server. It's part of the application code rather than the infra. Add hybrid component used in both server/client and an extra component shared by multiple entry points. * Use require.extensions to replace .client imports The simplest server doesn't need AOT compilation. Instead we can just configure require.extensions. This is probably not the best idea to use in prod but is enough to show the set up.
- Loading branch information
1 parent
1b85f59
commit 6e47e76
Showing
8 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,19 @@ | ||
import * as React from 'react'; | ||
|
||
import Container from './Container'; | ||
|
||
import Counter from './Counter.client'; | ||
|
||
import ShowMore from './ShowMore.client'; | ||
|
||
export default function App() { | ||
return ( | ||
<Container> | ||
<h1>Hello, world</h1> | ||
<Counter /> | ||
<ShowMore> | ||
<p>Lorem ipsum</p> | ||
</ShowMore> | ||
</Container> | ||
); | ||
} |
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,5 @@ | ||
import * as React from 'react'; | ||
|
||
export default function Container({children}) { | ||
return <div>{children}</div>; | ||
} |
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,6 +1,12 @@ | ||
import * as React from 'react'; | ||
|
||
import Container from './Container'; | ||
|
||
export default function Counter() { | ||
const [count, setCount] = React.useState(0); | ||
return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>; | ||
return ( | ||
<Container> | ||
<button onClick={() => setCount(c => c + 1)}>Count: {count}</button> | ||
</Container> | ||
); | ||
} |
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,11 @@ | ||
import * as React from 'react'; | ||
|
||
import Container from './Container'; | ||
|
||
export default function ShowMore({children}) { | ||
const [show, setShow] = React.useState(false); | ||
if (!show) { | ||
return <button onClick={() => setShow(true)}>Show More</button>; | ||
} | ||
return <Container>{children}</Container>; | ||
} |
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