home: do not re-render child when parent is re-rendered
This commit is contained in:
parent
182c225528
commit
d2957f3b2c
|
@ -29,13 +29,17 @@ class Home extends React.Component
|
||||||
className="switch-wrapper"
|
className="switch-wrapper"
|
||||||
>
|
>
|
||||||
<Redirect exact from="/" to="/paste/text" />
|
<Redirect exact from="/" to="/paste/text" />
|
||||||
|
{
|
||||||
|
# Use `render` instead of `component` to prevent re-rendering the child
|
||||||
|
# when parent is re-rendered (however this prevents passing match props)
|
||||||
|
}
|
||||||
<Route
|
<Route
|
||||||
exact path="/paste/text"
|
exact path="/paste/text"
|
||||||
component={() => <Pastebin openDialog={@openDialog}/>}
|
render={() => <Pastebin openDialog={@openDialog}/>}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact path="/paste/binary"
|
exact path="/paste/binary"
|
||||||
component={() => <BinaryUpload openDialog={@openDialog}/>}
|
render={() => <BinaryUpload openDialog={@openDialog}/>}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/paste/:id"
|
path="/paste/:id"
|
||||||
|
|
Loading…
Reference in a new issue