Skip to content

Commit

Permalink
add more examples for hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz committed Mar 16, 2019
1 parent b54d50f commit 0ffce95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 5 additions & 6 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import * as MessageSource from 'react-message-source';
import { Provider as MessageSourceProvider } from 'react-message-source';

import Hooks from './Hooks';
import {
LocalizedLabel,
LocalizedLabelCurried,
Expand All @@ -18,15 +19,13 @@ export default function App() {
<React.Fragment>
<p>The content below is localized, see Greeting.js for more information.</p>

<MessageSource.Provider value={translations}>
<MessageSourceProvider value={translations}>
<LocalizedLabel />

<LocalizedLabelCurried />

<PrefixedLocalizedLabel />

<LocalizedLabelWithNamedParams />
</MessageSource.Provider>
<Hooks />
</MessageSourceProvider>
</React.Fragment>
);
}
7 changes: 7 additions & 0 deletions example/src/Hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import { useMessageSource } from 'react-message-source';

export default function Hooks() {
const { getMessage } = useMessageSource();
return <span>Translation with a hook: {getMessage('hello.world')}</span>;
}

0 comments on commit 0ffce95

Please sign in to comment.