Fork me on GitHub
#reagent
<
2019-11-24
>
achikin13:11:08

I'm looking at the create-class docs here http://reagent-project.github.io/docs/master/reagent.core.html and it says that I can add :constructor but when I do it - React shows an error create-react-class.inc.js:1170 Uncaught Invariant Violation: ReactClassInterface: You are attempting to define constructor on your component more than once. This conflict may be due to a mixin.

p-himik14:11:17

Are you using Reagent 0.9.0?

p-himik14:11:20

Well there you go. 🙂 According to git blame, :constructor has been there for only 3 months, and 0.8.1 is much older.

achikin14:11:58

Thank you! 🙂

p-himik14:11:39

No problem. Oh, the documentation page itself says "Reagent 0.9.0-rc3". But I cannot find any way to switch it to a different version.

achikin14:11:05

Yes, my bad - I didn't check that 😞

achikin14:11:42

Anyway I just wanted to be sure that I'm not using a deprecated :get-initial-state

p-himik14:11:33

Why is it deprecated? I cannot find any information about it.

achikin14:11:15

The same doc says `State can be initialized using constructor, which matches React.Component class, or using getInitialState which matches old React createClass function and is now implemented by Reagent for compatibility.`

p-himik14:11:11

But it doesn't mean that getInitialState is deprecated. Old, yes. Deprecated, no.

achikin14:11:24

That's why I was trying to change to :constructor . The words "old" and "compatibility" triggered me 🙂

p-himik14:11:38

In fact, the official documentation still mentions it for the situations when you cannot use ES6 classes: https://reactjs.org/docs/react-without-es6.html#setting-the-initial-state

achikin14:11:54

Thank you for pointing me at that doc. I've checked https://reactjs.org/docs/react-component.html and didn't find any mentions of getInitialState

p-himik14:11:22

Oh, that's neat, thanks!

juhoteperi14:11:54

I've updated the readme to have separate links for 0.8 and 0.9 docs, there are several things in current docs that don't work with 0.8

juhoteperi14:11:22

As React docs say, using React without ES6 requires create-react-class which 0.8 uses but 0.9 will instead create ES6 classes