Has anyone been able to setup create react app with semantic-ui? - reactjs

If so, please share folder structure (where is semantic path) and an example of importing a component.

I know this question is rather "old" (in a front-end dev sense), but Semantic UI now has official React integration and bindings:
Semantic UI React
https://react.semantic-ui.com/
Among its key features (from the landing page):
jQuery Free
All jQuery functionality has been re-implemented in React.
Declarative API
Declarative APIs provide for robust features and prop validation.
Augmentation
Control the rendered HTML tag, or render one component as another component. Extra props are passed to the component you are rending as.
Shorthand Props
Shorthand props generate markup for you, making many use cases a breeze. All object props are spread on the child components.
Sub Components
Sub components give you complete access to the markup. This is essential for flexibility in customizing components.
Auto Controlled State
Our stateful components self manage their state out of the box, without wiring. Dropdowns open on click without wiring onClick to the open prop. The value is also stored internally, without wiring onChange to value.
Installation
$ npm install semantic-ui-react --save
$ npm install semantic-ui-css --save
or if you prefer Yarn:
$ yarn add semantic-ui-react
$ yarn add semantic-ui-css
After installing, include this line in your index.js file:
import 'semantic-ui-css/semantic.min.css';

I will make use of the react package https://react.semantic-ui.com/ . Same stuff but without jquery and all react components

Related

Adding React to a site; use of hooks/functional components

I am very new to react and need to rebuild two Angular.js components within a .NET Content Management System (Kentico). I do not believe there is an opportunity to run a react app/component through npm so I have gone the other route and "add React to a website" (https://reactjs.org/docs/add-react-to-a-website.html). I'm using browserify with babelify to compile my app/component code for the browser.
I've made some decent progress but believe I like the flexibility functional components bring to the table where I don't find coding within a class component all that familiar. Because I'm "adding React to a site" instead of running it through npm, I BELIEVE I have no opportunity to import hooks and thus: no opportunity for useState within functional components.
Can anyone verify this for me? That indeed, "adding react to a site" precludes one from using functional components: class components are the best I can do?
I guess it boils down to: I do not believe I can import useState/useEffect when I am "adding react to a site" in a way where react and react-dom are just script references at the base of my component.
Maybe someone can verify that for me or else point out how I would capitalize on functional components/hooks?
You can use hooks and classes freely no matter how you include them. It's not relevant. The old react docs only use classes which is confusing. Try beta docs: https://beta.reactjs.org/

Functional component with warning in development : Function components cannot be given refs. ...Did you mean to use React.forwardRef()?

I have a question regarding the use of a plugin that I created, and used in an application called HRnet (React 18).
I have no warning in development on the plugin side. But in development on the application side I always have this warning from the bundle.js (but not in production):
It's related to my plugin (no more warning when I comment my plugin), but I don't understand why.
My plugin is a dropdown, it is published on NPM, for the bundler I used Rollup, and lifting state up to pass the value.
NPM
plugin: https://www.npmjs.com/package/react-dropdown-component-library
CodeSandbox (updated)
Dropdown (plugin): https://codesandbox.io/s/dropdown-pybhpn?file=/src/lib/index.tsx
HRNet (app): https://codesandbox.io/s/hrnet-9xq0qv?file=/src/components/AddUseForm/index.tsx:8850-8851
This is probably because register from react-hook-form returns a ref, and it is required by that library that the component it is attached to connects it to the actual form node.
However your dropdown is custom and doesn't use a base HTML element so you need to just not attach it instead. See https://react-hook-form.com/faqs/#Whatifyoudonthaveaccesstoref

Is there any difference between jsx bootstrap and simple bootstrap?

i am beginner in react js, using jsx bootstrap in react js, i have watched many videos in youtube some using jsx react and some using simple bootstrap with minimal classname change,that's why i got confused
what have to use react bootstrap or simple bootstrap
As it is documented in Bootstrap official website, "React-Bootstrap replaces the Bootstrap JavaScript. Each component has been built from scratch as a true React component, without unneeded dependencies like jQuery."
It is moreover stated that React-Bootstrap is a complete re-implementation of the Bootstrap components using React. It has no dependency on either bootstrap.js or jQuery. Hence, the dependencies on Jquery and Bootstrap.js are eliminated.
Methods and events using jQuery is done imperatively by directly manipulating the DOM. In contrast, React uses updates to the state to update the virtual DOM. In this way, React-Bootstrap provides a more reliable solution by incorporating Bootstrap functionality into React's virtual DOM.
If you are using React, React-Bootstrap would be a better option, as you will not need to add scripts such as jquery.js or bootstrap.js to your code. The React component model gives more control over form and function of each component.

How can I implement Owl Carousel in react without use the Owl Carousel 2 component?

How can I implement Owl Carousel 2 in react, when I use the Owl Carousel 2 component needs updates:
react-dom.development.js:12357 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See fb.me/react-unsafe-component-lifecycles for details.
Move data fetching code or side effects to componentDidUpdate.
If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: fb.me/react-derived-state
Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.
Please update the following components: OwlCarousel
So, I wonder how can I implement the library in React without the component OwlCarousel2 .
Thanks.
As per Owl Carousel's Github repo its deprecated.
https://github.com/OwlCarousel2/OwlCarousel2
They recommend to use following: https://github.com/ganlanyuan/tiny-slider

How can I execute code with render of react components in runtime

Hello,
I have some react components in my project. And I would like to make the sandbox for users where they can try some properties of the components. I see this like textarea with jsx code and div with result of code.
My components have ES6 syntax and export default components and some non-default data(eg. properties of component).
I tried to transform es6 and jsx with babel then execute eval on the client side. But I couldn't connect the dependencies for component. Especially it was for non-default data.
If i try to compile bundle with webpack on the server side I work in memory file system and I have to load all dependencies from node modules there too.
Do you have any ideas how can I do it? Maybe I missed something?

Resources