When an action is dispatched, useSelector() will do a reference comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, the component will not re-render.
export default (props) => {
return (
<Label className={props.className}>
{ props.children }
</Label>
)
}
import styled from 'styled-components';
export const Label = styled.div`
border: none;
border-radius: 20px;
background-color: #f63;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
height: 40px;
`;
export default Label;
const Hello = createContext<string>('Hello');
export default Hello;
import Hello from 'HelloContext';
import MyComponent from 'MyComponent';
function App() {
return (
<Hello.Provider value='Hi'>
<MyComponent />
</Hello.Provider>
);
}
export default App;
import HelloContext from 'HelloContext';
const MyComponent: React.FC<> = () => {
const msg = useContext(HelloContext );
return (
<span>{msg}</span>
)
}
export default MyComponent;
</Theme.Provider> <-- откуда Theme?