1.0.12 • Published 1 year ago

spake-react-sdk v1.0.12

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

How to use

spake-react-sdk is meant to be used in tandem with spake-cli to manage localized strings and set desired language.

  1. after strings localized strings have been generated via spake-cli
  2. wrap app with a SpakeProvider
  3. import strings and setLangage from spake state and dispatch hooks

File Structure

SpakeProvider will look for json files in src/strings

src
  -- strings
    -- strings_en.json
    -- strings_es.json

Example

import React from 'react'
import SpakeProvider, { useSpakeState, useSpakeDispatch } from 'spake-react-sdk'

const App = () => {
  return (
    <SpakeProvider>
      <Component />
    </SpakeProvider>
  )
}


const Component = () => {
    const { strings } = useSpakeState()
    const { setLanguage } = useSpakeDispatch()

    return (
        <>
            <div>{strings.helloWorld}<div/>
            <button onClick={() => {
                setLanguage('es')
            }}>Spanish<button/>
        </>
    )
}
1.0.11

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago