adapt-react-class is not bundled as a part of scittle. I went through sci.configs and it doesn't seem to be there. Is there any specific reason? I would like to use a CSSTransitionGroup component that is already bundled. I might be able to do it without adapting the react class
PR welcome
I think @jayzawrotny also mentioned some missing things a while back
:> is though
Well not bundled, but supported. https://cljdoc.org/d/reagent/reagent/1.1.1/doc/tutorials/interop-with-react#creating-reagent-components-from-react-components
@srijayanth [:> CSSTransitionGroup {} ...] should do it
Excellent! Thank you very much!
Still a PR would be in order for the next person who is going to hit this :)
Fair enough. Might have some time today
@borkdude - I am trying to run the tests for sci.configs but there are a bunch of issues:
1. The sci dependency in deps.edn is for the version SHA 95d04fc356adf50a6e36cfa4f5a0540300f326f3. This version doesn't have a required namespace (sci.ctx-store).
2. Using the latest SHA still fails because ctx isn't explicitly set in the tests
3. Explicitly setting the ctx by using sci.ctx-store/reset-ctx runs the tests.
I want to raise a PR for including adapt-react-class . Should I fix this and issue it as a part of the same PR? It will require an updation of the deps.edn to use the latest sci or at least a version that includes ctx-store.yes to all
thanks!
https://github.com/babashka/sci.configs are there tests there for the reagent functions?
Not really. I need to add a test runner, I'll do this later today
Added the test runner + reagent test
How would I write a test that uses a js class? I’d have to somehow give the ctx a way to know what my symbol means. But this is sort of a fake test since I’ll entirely be in cljs land whereas the original class will be some sort of js/Foo .
I mean, I can choose not to have the test since all we’re doing is including one more var, adapt-react-class … maybe the test is simply that the var exists
Could write a simplified React class in a JS file, then import it into the test file, render it to a string, and test the markup
My instinct would either be to not include a test since it's just the long way of doing [:> MyClass] or doing a full test like described above. I feel like having a test that only proves the var exists may lead to false positives
Yeah 😐
I won’t include the test.
It is a lot of work and tests somebody else’s code, not ours 😄
export default class TestView extends React.Component {
render () {
return React.createElement('div', "Content")
}
}
That should do it, saved as a fixtureWould have to import this as well.
(require ["./test/fixtures/TestView.js" :as TestView])
The test runner doesn’t pickup the fixture. I am not sure how the test runner loads js dependencies.
If you want to push up what you have I could give it a shot
Right now, I’m just playing around to see how to get a test going with an external js lib. One way is to use package.json. I’ll spend some more time with it. I want to understand this better
This is the sci.configs repo?
Yeah.
According to the cljs test runner docs, the tests are ran through node. What does (println (js/process.cwd)) display in the test file?
Worst case could do (def TestView (js/require "../test/fixtures/TestView.js"))
The correct path will depend on the current working directory of the test script though
If that still doesn't work, could ditch the js file and use the reagent create-react-class API https://cljdoc.org/d/reagent/reagent/1.1.1/api/reagent.core#create-class in the test file. The js version is more realistic though
If this is an oversight, I can simply provide a PR to sci.configs