Code Monkey home page Code Monkey logo

Comments (2)

jamuhl avatar jamuhl commented on September 6, 2024

Your first react app?

import React from 'react';
import logo from './logo.svg';
import './App.css';

const App = (props) => {
  const {t} = props;

  return (
    <div className="App">
      <header className="App-header">
        <p>React test</p>
      </header>
      <div>
      {t("Introduction")}
      </div>
    </div>
  );
}

export default App;

Why should the t function be in the props? You did not add it and no HOC is used. In react there is no way to get things into the props magically -> use https://react.i18next.com/latest/withtranslation-hoc

or better https://react.i18next.com/latest/usetranslation-hook in functional components...

hope this helps...also be aware to use Suspense or turn that off (Suspense component must be outside the component using HOC or hook) https://react.i18next.com/latest/usetranslation-hook#not-using-suspense (you can turn that off globally too - but Suspense is nice - learn about it)

from i18next-gitbook.

totaldict avatar totaldict commented on September 6, 2024

At the end of app.js, try to wrap your component when exporting:
const enhance = compose(withTranslation());
export default (enhance(App);

and don't forget the imports you need:
import {compose} from 'redux';
import {withTranslation} from 'react-i18next';
This is how it works for me.

from i18next-gitbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.