Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React class parse error #93

Closed
deema089786 opened this issue Jul 26, 2018 · 8 comments
Closed

React class parse error #93

deema089786 opened this issue Jul 26, 2018 · 8 comments

Comments

@deema089786
Copy link

I am using i18next-scanner for get strings from my components. But if I use class field like this

export default class Main extends Component {
static testvalue = 12;
render(){return(<div><Trans>some string</Trans></div>)}
}

"static testvalue = 12" cause this error

18next-scanner: Unable to parse Trans component with the content
{ SyntaxError: Unexpected token (10:19)

If I don't use this way for define class fields all works good. How can I fix it?

@cheton
Copy link
Member

cheton commented Jul 27, 2018

Related to #86

@saravanan10393
Copy link

saravanan10393 commented Aug 7, 2018

@cheton
This also fails when react class has properties

class Todo extends React.Component{ todos = []; addTodo = (task) => { this.todos.push(task) } }

In my project, i prefer using property function instead of member function to avoid binding to this instance.

Please help.
I am thinking to use React18next for project.

@LuisSaybe
Copy link

any updates?

@daliusd
Copy link
Contributor

daliusd commented Nov 26, 2018

Check my answer on #88 for some ideas.

@ctavan
Copy link
Contributor

ctavan commented Nov 28, 2018

@deema089786 @saravanan10393 @LuisSaybe can you check if #112 (npm install @contentpass/i18next-scanner) fixes the issue for you?

@ctavan
Copy link
Contributor

ctavan commented Nov 29, 2018

@deema089786 @saravanan10393 @LuisSaybe since my patch has been released, can you check again with [email protected]?

@deema089786
Copy link
Author

2.8.0 - all works perfectly. Thanks.
Tested with this code
image

@LuisSaybe
Copy link

@ctavan works now with latest, thanks so much for giving your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants